> ## 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 Liquidation Stats

> Aggregate liquidation counters from chain and from Trusset records

Returns liquidation totals from two sources side by side: counters read from the market contract, and record counts grouped by status from the Trusset database.

The endpoint reconciles pending liquidations from the chain before counting, so adopted records are included.

## Path Parameters

<ParamField path="marketId" type="string" required>Market ID.</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="onChain" type="object">
      Contract counters, or null when the read failed.

      <Expandable>
        <ResponseField name="totalLiquidations" type="integer">Lifetime liquidations on this market.</ResponseField>
        <ResponseField name="pendingLiquidationDebt" type="string">Debt seized but not yet settled, in borrow asset units.</ResponseField>
        <ResponseField name="totalAuctions" type="integer">Lifetime Dutch auctions created.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="database" type="object">
      <Expandable>
        <ResponseField name="pending" type="integer">Liquidations awaiting settlement.</ResponseField>
        <ResponseField name="settled" type="integer">Liquidations closed with proceeds routed back to the market.</ResponseField>
        <ResponseField name="writtenOff" type="integer">Liquidations written off after the 7 day timeout, with bad debt covered by the insurance fund.</ResponseField>
        <ResponseField name="stuck" type="integer">Always `0` for external securities markets. See the note below.</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  `stuck` counts intermediate states produced by the automated sell orchestrator, which external securities markets do not use. It is always `0` here and carries no signal. A settlement that has genuinely stalled shows up as a long-lived `pending` record. Compare `createdAt` on [Get Pending Liquidations](/endpoints/external-securities-lending/get-pending-liquidations) against the 7 day write-off window to find them.
</Note>

<Tip>
  `onChain.pendingLiquidationDebt` above zero with `database.pending` at zero means the chain holds unsettled debt the backend has not recorded. Call [Get Pending Liquidations](/endpoints/external-securities-lending/get-pending-liquidations), which runs a reconciliation pass and adopts anything missing.
</Tip>

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

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "onChain": {
        "totalLiquidations": 5,
        "pendingLiquidationDebt": "21159.200000",
        "totalAuctions": 2
      },
      "database": {
        "pending": 1,
        "settled": 3,
        "stuck": 0,
        "writtenOff": 1
      }
    }
  }
  ```
</ResponseExample>
