> ## 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. Archived and inactive markets are excluded.

The stored aggregates are served by default and `onChain` is `null`. Live per-market state is opt-in through `includeOnChain`, because enriching a list runs a full position sync per market and turns a list read into an unbounded chain scan. For live state on a single market, prefer [Get Market](/endpoints/lending/get-market) or [Get Market Metrics](/endpoints/lending/get-metrics).

When enrichment is requested it is still best effort. If the RPC is unreachable for a given market, `onChain` comes back `null` and the stored fields are served regardless. Always check `onChain` before reading from it.

## Query Parameters

<ParamField query="includeOnChain" type="boolean" default="false">
  Set to `true` to read live contract state for every market in the list. Any other value leaves `onChain` as `null`.
</ParamField>

## 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 own liquidation router. Every market has one for life, and there is no shared 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="saleRecipient" type="string">Where seized collateral is sent for realization. Fixed by the lender of record when it took the role and not rotatable afterwards.</ResponseField>
        <ResponseField name="priceSource" type="string">`NAV`, `MARKET` or `ORACLE`.</ResponseField>
        <ResponseField name="externalOracleFeed" type="string">The external feed an `ORACLE` market reads. `null` on every other price source.</ResponseField>
        <ResponseField name="collateralTokenAddress" type="string">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="collateralDecimals" type="integer">Decimals of the collateral token. Every collateral amount on this surface is formatted at this scale.</ResponseField>
        <ResponseField name="identityRegistryAddress" type="string">The market's identity gate, or `null` when none is installed.</ResponseField>
        <ResponseField name="borrowAssetAddress" type="string">Settlement token the market lends and is repaid in.</ResponseField>
        <ResponseField name="borrowAssetSymbol" type="string">Its symbol, for example `USDC`.</ResponseField>
        <ResponseField name="borrowAssetDecimals" type="integer">Its decimals. Every borrow-side amount is formatted at this scale.</ResponseField>
        <ResponseField name="permitSupported" type="boolean">Whether the settlement asset implements EIP-2612, so [Repay Loan](/endpoints/lending/repay) can take a single-signature `permit`. `null` until probed.</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="liquidationBonus" type="string">Liquidator incentive in basis points.</ResponseField>
        <ResponseField name="closeFactor" type="string">Maximum fraction of debt repayable in one liquidation, in basis points.</ResponseField>
        <ResponseField name="maxTotalCollateral" type="string">Supply cap across the market, in collateral units. `"0"` means uncapped.</ResponseField>
        <ResponseField name="maxUserCollateral" type="string">Supply cap per borrower, in collateral units. `"0"` means uncapped.</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="isOnChain" type="boolean">Whether the market has a deployed address recorded.</ResponseField>
        <ResponseField name="onChain" type="object">Live contract metrics. `null` unless `includeOnChain=true`, and `null` when the read failed. See [Get Market Metrics](/endpoints/lending/get-metrics) for the full field list.</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

### Lender of record

<ResponseField name="data.markets" type="array">
  <Expandable>
    <ResponseField name="curator" type="string">The institution holding the lender-of-record role, or `null` while the market is still seeking one.</ResponseField>
    <ResponseField name="seekingCurator" type="boolean">`true` while no institution has taken the role. Every money path on the market is refused with `MARKET_PENDING_CURATOR` while this holds.</ResponseField>
    <ResponseField name="curatorImported" type="boolean">Whether this row exists because the instance took the role on another platform's market, rather than because it deployed the market itself.</ResponseField>
    <ResponseField name="realizationMode" type="string">How the lender of record declared it will realize seized collateral: `EXCHANGE_SALE`, `ISSUER_REDEMPTION` or `AUCTION`.</ResponseField>
    <ResponseField name="liquidityCommitment" type="string">Liquidity the lender of record committed when it took the role, in borrow asset units.</ResponseField>
  </Expandable>
</ResponseField>

### Rate and term offering

Fixed at deployment and healed from the chain whenever the market is read. All rate values are basis-point strings, all durations are strings of seconds.

<ResponseField name="data.markets" type="array">
  <Expandable>
    <ResponseField name="rateMode" type="string">`CURVE`, `CLAMPED` or `FIXED`.</ResponseField>
    <ResponseField name="rateFloor" type="string">Floor the model holds to. `"0"` on `CURVE`.</ResponseField>
    <ResponseField name="rateCap" type="string">Cap the model holds to. `"0"` on `CURVE`.</ResponseField>
    <ResponseField name="maxFixedRate" type="string">Ceiling the lender of record may stamp a fixed rate at, or `null`.</ResponseField>
    <ResponseField name="operatorShare" type="string">Share of post-infrastructure interest that goes to the lender of record, in basis points. It is one of the three deductions between the borrow rate and the supply rate.</ResponseField>
    <ResponseField name="reserveRatio" type="string">Share of the pool held back from borrowing, in basis points.</ResponseField>
    <ResponseField name="maxLoanDuration" type="string">Seconds a loan may run before it falls due. `"0"` means the market makes open-ended loans.</ResponseField>
    <ResponseField name="termGracePeriod" type="string">Seconds after the due date before the term penalty applies.</ResponseField>
    <ResponseField name="terminalDueDate" type="string">Unix seconds every loan falls due by, whatever its own duration, or `null`.</ResponseField>
    <ResponseField name="termPenalty" type="string">Penalty applied past the grace period, in basis points.</ResponseField>
    <ResponseField name="marketDueFloor" type="string">Earliest due date the market will accept, or `null`.</ResponseField>
    <ResponseField name="allowExtension" type="boolean">Whether a borrower may be granted more time on a termed loan.</ResponseField>
  </Expandable>
</ResponseField>

### Oracle staleness

Read once per oracle across the whole list and attached to every market, so the list is safe to poll.

<ResponseField name="data.markets" type="array">
  <Expandable>
    <ResponseField name="isStale" type="boolean">Whether the stored price is older than the market's `maxPriceAge`. `null` when the oracle could not be read, which is not the same as fresh.</ResponseField>
    <ResponseField name="priceAge" type="integer">Seconds since the last price update, or `null`.</ResponseField>
    <ResponseField name="maxPriceAge" type="integer">The staleness bound in seconds, or `null`.</ResponseField>
    <ResponseField name="oracleLastUpdate" type="string">When the price was last pushed, or `null`.</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?includeOnChain=true" \
    -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?includeOnChain=true',
    { 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",
          "curator": "0x4e91a7c05d3b62f18a0c94e7db2358f1c60a4e93",
          "seekingCurator": false,
          "curatorImported": false,
          "realizationMode": "EXCHANGE_SALE",
          "liquidityCommitment": "1000000",
          "borrowAssetSymbol": "USDC",
          "borrowAssetDecimals": 6,
          "collateralDecimals": 18,
          "permitSupported": true,
          "rateMode": "CLAMPED",
          "rateFloor": "200",
          "rateCap": "1200",
          "maxFixedRate": null,
          "operatorShare": "1000",
          "reserveRatio": "500",
          "maxLoanDuration": "15552000",
          "termGracePeriod": "432000",
          "terminalDueDate": null,
          "termPenalty": "300",
          "marketDueFloor": null,
          "allowExtension": true,
          "isStale": false,
          "priceAge": 3241,
          "maxPriceAge": 86400,
          "oracleLastUpdate": "2025-06-15T11:06:00.000Z",
          "active": true,
          "createdAt": "2025-06-01T09:00:00.000Z",
          "isOnChain": true,
          "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>
