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

# Get historical collateral holders

> Returns, for each holder, the integral of their collateral balance over the requested time window — expressed as deposit-seconds (decimal-adjusted collateral units multiplied by seconds held). Useful for time-weighted depositor rewards, retroactive incentive splits, etc.

Event sources folded in:
  * AddCollateral (+amount, decimal-adjusted)
  * RemoveCollateral (−amount)
  * Liquidate (−sum of collateralTransfers[] matching the target mint where toLiquidator = true; the row's top-level amount is principal repaid and is ignored for collateral accounting)

Events with eventTime < rangeStart are collapsed into a single bucket at rangeStart so they establish the starting balance for the window. Events at exactly rangeEnd contribute zero seconds.

The mint filter is applied against loan_events_v1.asset_identifier for Add/Remove events and against per-transfer assetMint inside Liquidate metadata. For single-mint collateral these are equal; for CLP/LP collateral, asset_identifier is the pool id — callers should pass the pool id, not an underlying token mint.



## OpenAPI

````yaml post /markets/collateral/holders/historical
openapi: 3.1.0
info:
  title: Loopscale API
  version: 0.1.0
servers:
  - url: https://tars.loopscale.com/v1
    description: Loopscale Production Server
security: []
paths:
  /markets/collateral/holders/historical:
    post:
      tags:
        - stats
      summary: Time-weighted historical collateral deposits per holder
      description: >-
        Returns, for each holder, the integral of their collateral balance over
        the requested time window — expressed as deposit-seconds
        (decimal-adjusted collateral units multiplied by seconds held). Useful
        for time-weighted depositor rewards, retroactive incentive splits, etc.


        Event sources folded in:
          * AddCollateral (+amount, decimal-adjusted)
          * RemoveCollateral (−amount)
          * Liquidate (−sum of collateralTransfers[] matching the target mint where toLiquidator = true; the row's top-level amount is principal repaid and is ignored for collateral accounting)

        Events with eventTime < rangeStart are collapsed into a single bucket at
        rangeStart so they establish the starting balance for the window. Events
        at exactly rangeEnd contribute zero seconds.


        The mint filter is applied against loan_events_v1.asset_identifier for
        Add/Remove events and against per-transfer assetMint inside Liquidate
        metadata. For single-mint collateral these are equal; for CLP/LP
        collateral, asset_identifier is the pool id — callers should pass the
        pool id, not an underlying token mint.
      operationId: query_get_historical_collateral_summary
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HistoricalCollateralHolderFilter'
        required: true
      responses:
        '200':
          description: Historical collateral holder summary
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/HistoricalCollateralHolderStats'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    HistoricalCollateralHolderFilter:
      type: object
      required:
        - mint
        - rangeStart
        - rangeEnd
      properties:
        mint:
          type: string
        pdas:
          type: boolean
        rangeEnd:
          type: integer
          format: int64
        rangeStart:
          type: integer
          format: int64
    HistoricalCollateralHolderStats:
      type: object
      description: |-
        Historical holder summary for one collateral mint over `[rangeStart,
        rangeEnd]`: per-holder deposit-seconds (time-weighted exposure).
      required:
        - collateralMint
        - rangeStart
        - rangeEnd
        - userDepositSeconds
      properties:
        collateralMint:
          type: string
        rangeEnd:
          type: integer
          format: int64
        rangeStart:
          type: integer
          format: int64
        userDepositSeconds:
          type: object
          additionalProperties:
            type: number
            format: double
          propertyNames:
            type: string
    ErrorResponse:
      type: object
      description: |-
        Canonical error envelope for every endpoint. The `x-request-id` response
        header carries the correlation id for the failing request.
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetails'
          description: error detail
    ErrorDetails:
      type: object
      description: Inner detail of the [`ErrorResponse`] envelope.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
          description: HTTP status code, mirrored in the response status line
          example: 400
          minimum: 0
        message:
          type: string
          description: human-readable, client-safe message (sensitive data redacted)
          example: Request could not be processed.

````