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

# Report Partial Sale

> Deposit interim sale proceeds into the router

Records proceeds from a partial sale of seized collateral and transfers them from the signing wallet into the liquidation router. Use it when a position is being sold down in tranches and you want proceeds banked as they arrive, rather than held off-platform until the final settlement.

The endpoint is repeatable. Each call increases the router's `proceedsCollected`.

<Warning>
  The signing wallet must be holding the proceeds. This call pulls the borrow asset from that wallet into the router, so fund it before broadcasting. An insufficient balance reverts on-chain.
</Warning>

## Path Parameters

<ParamField path="liquidationId" type="string" required>
  Liquidation ID on the market's router.
</ParamField>

## Body Parameters

<ParamField body="marketId" type="string">
  Names the market whose liquidation you mean. Every market runs its own liquidation router and IDs restart at `1` on each of them, so the same `liquidationId` can exist on several markets in one instance. Supply this when it does, otherwise the call is refused with `AMBIGUOUS_LIQUIDATION_ID` and the response lists the candidates.
</ParamField>

<ParamField body="collateralSold" type="string" required>
  Collateral disposed of in this tranche, as a decimal string in collateral token units. Must be greater than zero.
</ParamField>

<ParamField body="usdcProceeds" type="string" required>
  Proceeds realised, as a decimal string in the market's borrow asset. Must be greater than zero.
</ParamField>

<ParamField body="txHash" type="string">
  Hash of the transaction you broadcast for this operation. Send it to confirm the transaction and record the result. Omit it to receive the calldata.
</ParamField>

<Note>
  The signing wallet must hold `OPERATOR_ROLE` on the router. If it does not, the calldata is not returned: the response carries `ROUTER_OPERATOR_ROLE_MISSING` along with the `calldata` that grants the role.
</Note>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="liquidationId" type="string">Liquidation ID, echoed back.</ResponseField>
    <ResponseField name="collateralSold" type="string">Collateral reported, echoed back.</ResponseField>
    <ResponseField name="usdcProceeds" type="string">Proceeds deposited.</ResponseField>
    <ResponseField name="txHash" type="string">Transaction hash.</ResponseField>
    <ResponseField name="success" type="boolean">Nested inside `data` on the calldata response.</ResponseField>
    <ResponseField name="action" type="string">`SIGN_TRANSACTIONS`. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="steps" type="array">Ordered `approve` on the borrow asset, then `reportPartialSale`. Returned when `txHash` is omitted.</ResponseField>
  </Expandable>
</ResponseField>

<Note>
  `collateralSold` is recorded in the on-chain event as an audit trail. It does not reduce `collateralRemaining` on the router, because the collateral left the router when you called [Withdraw Collateral for Sale](/endpoints/lending/withdraw-collateral-for-sale). Only that endpoint moves the balance.
</Note>

Proceeds deposited here stay in the router until [Settle Liquidation](/endpoints/lending/settle-liquidation) forwards the cumulative total to the market. Reporting partial sales alone never closes a liquidation, and the record stays `PENDING`.

## Settling After Partial Sales

Once every tranche has been reported, call [Settle Liquidation](/endpoints/lending/settle-liquidation) with `usdcProceeds` of `"0"`. Settlement forwards the full `proceedsCollected` balance already sitting at the router, so a zero final payment is valid and expected in this flow.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-external-securities/api/liquidations/report-partial-sale/14" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "collateralSold": "100",
      "usdcProceeds": "9800.00"
    }'
  ```

  ```typescript TypeScript theme={null}
  for (const tranche of tranches) {
    await fetch(
      `https://api.trusset.org/lending-external-securities/api/liquidations/report-partial-sale/${liquidationId}`,
      {
        method: 'POST',
        headers: {
          'X-API-Key': 'trusset_your_key_here',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          collateralSold: tranche.units,
          usdcProceeds: tranche.proceeds
        })
      }
    );
  }

  await fetch(
    `https://api.trusset.org/lending-external-securities/api/liquidations/settle/${liquidationId}`,
    {
      method: 'POST',
      headers: {
        'X-API-Key': 'trusset_your_key_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ usdcProceeds: "0" })
    }
  );
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "liquidationId": "14",
      "collateralSold": "100",
      "usdcProceeds": "9800.00",
      "txHash": "0xabc...def"
    }
  }
  ```

  ```json Error - Already Settled theme={null}
  {
    "success": false,
    "error": {
      "code": "ALREADY_SETTLED",
      "message": "Already settled"
    }
  }
  ```
</ResponseExample>

## Error Codes

| Code                           | HTTP  | Cause                                                                                                           |
| ------------------------------ | ----- | --------------------------------------------------------------------------------------------------------------- |
| `VALIDATION_ERROR`             | `400` | `collateralSold` or `usdcProceeds` is not a positive decimal string                                             |
| `AMBIGUOUS_LIQUIDATION_ID`     | `400` | This ID exists on more than one market in your instance. The error carries `candidates`; resend with `marketId` |
| `ALREADY_SETTLED`              | `400` | The liquidation is settled or written off                                                                       |
| `WALLET_NOT_CONFIGURED`        | `400` | No verified wallet is registered on this instance to resolve the signer against                                 |
| `ROUTER_OPERATOR_ROLE_MISSING` | `400` | The resolved wallet lacks `OPERATOR_ROLE`. The error carries grant `calldata`                                   |
| `ROUTER_NOT_CONFIGURED`        | `400` | No liquidation router resolved for this market                                                                  |
| `TX_NOT_VERIFIED`              | `400` | The confirmed transaction targets a different liquidation                                                       |
| `PARTIAL_SALE_TX_REVERTED`     | `400` | The report reverted. `error.txHash` carries the hash when one exists                                            |
| `PARTIAL_SALE_FAILED`          | `400` | The report could not be prepared and no more specific code applied                                              |
| `LIQUIDATION_NOT_FOUND`        | `404` | No liquidation with that ID on your instance, and none could be adopted from chain                              |
| `MARKET_NOT_FOUND`             | `404` | `marketId` was supplied but names no market on your instance                                                    |
