> ## 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.

# Get Router Stats

> Lifetime counters from a liquidation router

Returns cumulative totals from a liquidation router: how many liquidations it has received and settled, how much collateral has passed through it, and how much in proceeds it has routed back to markets.

Every market carries its own liquidation router, so `marketId` names which router to read and there is no aggregate to fall back on. Omitting it returns `MARKET_REQUIRED`.

## Query Parameters

<ParamField query="marketId" type="string" required>
  Market whose router to read. Maximum 100 characters.
</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="routerAddress" type="string">Router the figures came from.</ResponseField>
    <ResponseField name="totalReceived" type="string">Liquidations received over the router's lifetime.</ResponseField>
    <ResponseField name="totalSettled" type="string">Liquidations settled. The difference against `totalReceived` is the outstanding count.</ResponseField>
    <ResponseField name="totalCollateralProcessed" type="string">Collateral handled, formatted at the collateral token's decimals.</ResponseField>
    <ResponseField name="totalCollateralProcessedRaw" type="string">The same figure in base units.</ResponseField>
    <ResponseField name="totalProceedsRouted" type="string">Proceeds routed back to markets, formatted at the borrow asset's decimals.</ResponseField>
    <ResponseField name="totalProceedsRoutedRaw" type="string">The same figure in base units.</ResponseField>
  </Expandable>
</ResponseField>

<Note>
  A router serves one market, so these totals are market-level rather than protocol-level. To read across an instance, call this once per market from [List Markets](/endpoints/lending/list-markets) and add the figures yourself.
</Note>

## Error Codes

| Code                | HTTP  | Cause                                                                                          |
| ------------------- | ----- | ---------------------------------------------------------------------------------------------- |
| `MARKET_REQUIRED`   | `400` | `marketId` was omitted. Every market runs its own router, so there is no shared router to read |
| `STATS_UNAVAILABLE` | `400` | The router could not be reached, or it returned nothing readable                               |
| `MARKET_NOT_FOUND`  | `404` | `marketId` names no market on your instance                                                    |

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

  ```typescript TypeScript theme={null}
  const res = await fetch(
    `https://api.trusset.org/lending-external-securities/api/liquidations/router-stats?marketId=${marketId}`,
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();
  const outstanding = Number(data.totalReceived) - Number(data.totalSettled);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "routerAddress": "0x067a3feea46649adad8e31c33b3a4d8774b8d8cf",
      "totalReceived": "5",
      "totalSettled": "4",
      "totalCollateralProcessed": "1140.000000000000000000",
      "totalCollateralProcessedRaw": "1140000000000000000000",
      "totalProceedsRouted": "104820.500000",
      "totalProceedsRoutedRaw": "104820500000"
    }
  }
  ```

  ```json Error - Unavailable theme={null}
  {
    "success": false,
    "error": {
      "code": "STATS_UNAVAILABLE",
      "message": "Could not fetch router stats"
    }
  }
  ```

  ```json Error - Market Not Found theme={null}
  {
    "success": false,
    "error": {
      "code": "MARKET_NOT_FOUND",
      "message": "Market not found"
    }
  }
  ```
</ResponseExample>
