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

# List looped (leveraged) credit positions

> List looped (leveraged) positions for a credit account owner.

Detects loops from the account's on-chain history: a transaction containing
lending + borrowing + swap legs is a loop transaction. Returns one position
per Morpho market / Aave collateral+debt reserve pair, each with its complete
per-transaction history, lifetime totals, and live on-chain state (health
factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho
Blue.



## OpenAPI

````yaml /v2/combined_spec.json get /v2/credit/looped_positions
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/credit/looped_positions:
    get:
      tags:
        - Credit
      summary: List looped (leveraged) credit positions
      description: >-
        List looped (leveraged) positions for a credit account owner.


        Detects loops from the account's on-chain history: a transaction
        containing

        lending + borrowing + swap legs is a loop transaction. Returns one
        position

        per Morpho market / Aave collateral+debt reserve pair, each with its
        complete

        per-transaction history, lifetime totals, and live on-chain state
        (health

        factor, USD values, leverage) for open positions. Covers Aave V3 and
        Morpho

        Blue.
      operationId: v2_credit_looped_positions
      parameters:
        - name: chain
          in: query
          required: true
          schema:
            type: string
            enum:
              - arbitrum
              - base
              - bsc
              - ethereum
              - tempo
            title: Chain
            default: base
        - name: owner
          in: query
          required: true
          schema:
            type: string
            title: Owner
            default: '0x06A9aF046187895AcFc7258450B15397CAc67400'
          description: >-
            The address of the owner of the credit account to get looped
            positions for.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditLoopedPositionsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI, models


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.credit.credit_looped_positions(chain=models.V2CreditLoopedPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400")

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.credit.creditLoopedPositions({
                chain: "base",
                owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    CreditLoopedPositionsResponse:
      properties:
        credit_account_address:
          type: string
          title: Credit Account Address
          description: The credit product account address derived from the owner.
        positions:
          items:
            $ref: '#/components/schemas/LoopedPosition'
          type: array
          title: Positions
          description: All looped positions, on both Aave and Morpho.
          default: []
          example:
            - collateral_symbol: WETH
              collateral_token: '0x4200000000000000000000000000000000000006'
              current:
                collateral_amount: '3.0000000000'
                collateral_usd: '9000.0000000000'
                debt_amount: '5000.0000000000'
                debt_usd: '5000.0000000000'
                health_factor: '1.5480000000'
                health_factor_scope: market
                leverage: '2.2500000000'
                net_usd_value: '4000.0000000000'
              debt_symbol: USDC
              debt_token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
              history:
                - block_number: 25000000
                  block_timestamp: '2025-01-15T10:30:00Z'
                  classification: loop_open
                  collateral_delta: '3.0000000000'
                  debt_delta: '5000.0000000000'
                  events: []
                  iterations: 2
                  swap:
                    bought_amount: '1.6600000000'
                    bought_symbol: WETH
                    bought_token: '0x4200000000000000000000000000000000000006'
                    sold_amount: '5000.0000000000'
                    sold_symbol: USDC
                    sold_token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                  transaction_hash: >-
                    0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890
              market_id: >-
                0x8793cf302b8ffd655ab97bd1c695dbd967807e8367a65cb2f4edaf1380ba1bda
              opened_at: '2025-01-15T10:30:00Z'
              protocol: MORPHO
              status: OPEN
              totals:
                liquidation_count: 0
                loop_tx_count: 1
                total_collateral_added: '3.0000000000'
                total_collateral_removed: '0.0000000000'
                total_debt_added: '5000.0000000000'
                total_debt_removed: '0.0000000000'
                unwind_tx_count: 0
        aave_account_summary:
          anyOf:
            - $ref: '#/components/schemas/AccountSummary'
            - type: 'null'
          description: >-
            Aave account-level summary (health factor, LTV, borrow capacity).
            Present when the account holds any open Aave looped position, since
            Aave collateral is pooled and health is account-level. Null for
            Morpho-only accounts.
      type: object
      required:
        - credit_account_address
      title: CreditLoopedPositionsResponse
      description: Looped positions across Aave V3 and Morpho Blue for a credit account.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LoopedPosition:
      properties:
        protocol:
          $ref: '#/components/schemas/CreditProtocol'
          description: Lending protocol this position is on (AAVE or MORPHO).
        market_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Market Id
          description: 'Morpho only: the bytes32 id of the isolated market.'
        collateral_token:
          type: string
          title: Collateral Token
          description: Address of the collateral token.
        collateral_symbol:
          type: string
          title: Collateral Symbol
          description: Symbol of the collateral token.
        debt_token:
          type: string
          title: Debt Token
          description: Address of the debt token.
        debt_symbol:
          type: string
          title: Debt Symbol
          description: Symbol of the debt token.
        status:
          type: string
          enum:
            - OPEN
            - CLOSED
          title: Status
          description: Whether the position is currently open or fully closed.
        opened_at:
          type: string
          format: date-time
          title: Opened At
          description: Timestamp of the position's first transaction.
        closed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Closed At
          description: Timestamp the position was fully closed; null while open.
        current:
          anyOf:
            - $ref: '#/components/schemas/LoopedPositionCurrentState'
            - type: 'null'
          description: Live on-chain state; null for CLOSED positions.
        totals:
          $ref: '#/components/schemas/LoopedPositionTotals'
          description: Lifetime totals across the position's history.
        history:
          items:
            $ref: '#/components/schemas/LoopedPositionHistoryEntry'
          type: array
          title: History
          description: All transactions for this position, chronological.
          default: []
      additionalProperties: false
      type: object
      required:
        - protocol
        - collateral_token
        - collateral_symbol
        - debt_token
        - debt_symbol
        - status
        - opened_at
        - totals
      title: LoopedPosition
      description: A single looped (leveraged) position with its full history.
    AccountSummary:
      properties:
        protocol:
          $ref: '#/components/schemas/CreditProtocol'
          description: Lending protocol this summary describes.
          default: AAVE
        health_factor:
          type: string
          title: Health Factor
          description: Health factor. Above 1 is safe; below 1 risks liquidation.
        total_collateral_usd:
          type: string
          title: Total Collateral Usd
          description: Total collateral value in USD.
        total_debt_usd:
          type: string
          title: Total Debt Usd
          description: Total debt value in USD.
        available_borrows_usd:
          type: string
          title: Available Borrows Usd
          description: Available borrow capacity in USD.
        ltv:
          type: string
          title: Ltv
          description: Current loan-to-value ratio.
        emode_category_id:
          type: integer
          title: Emode Category Id
          description: >-
            E-Mode category ID. 0 = disabled. E-Mode gives higher LTV when
            collateral and debt are price-correlated (e.g.
            stablecoin-to-stablecoin or ETH-to-ETH-derivative).
          default: 0
        emode_label:
          anyOf:
            - type: string
            - type: 'null'
          title: Emode Label
          description: >-
            Human-readable E-Mode category name (e.g. 'Stablecoins', 'ETH
            correlated'). Null when E-Mode is disabled (category 0).
      additionalProperties: false
      type: object
      required:
        - health_factor
        - total_collateral_usd
        - total_debt_usd
        - available_borrows_usd
        - ltv
      title: AccountSummary
      description: >-
        Account-level summary for one lending protocol.


        Populated from Aave ``getUserAccountData()`` or, for Euler, from the

        controller vault's risk engine (``accountLiquidity``). The E-Mode fields
        are

        Aave-only and stay at their defaults for Euler.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CreditProtocol:
      type: string
      enum:
        - AAVE
        - EULER
        - MORPHO
      title: CreditProtocol
      description: >-
        Which lending protocol a credit action targets.


        ``AAVE`` is the default so existing callers (which never send a
        ``protocol``

        field) keep hitting the unchanged Aave code path. ``EULER`` opts in to
        the

        Euler V2 path, where the market is identified by EVK vault address(es).

        ``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id)
        and is

        currently read-only: positions and market discovery only — transaction

        builders land with the looping work (COM-7106/7107/7108), so transact

        endpoints reject it with a 422.
    LoopedPositionCurrentState:
      properties:
        collateral_amount:
          anyOf:
            - type: string
            - type: 'null'
          title: Collateral Amount
          description: Current on-chain collateral amount for this position.
        debt_amount:
          anyOf:
            - type: string
            - type: 'null'
          title: Debt Amount
          description: Current on-chain debt amount for this position.
        collateral_usd:
          anyOf:
            - type: string
            - type: 'null'
          title: Collateral Usd
          description: Collateral value in USD (null if unpriced).
        debt_usd:
          anyOf:
            - type: string
            - type: 'null'
          title: Debt Usd
          description: Debt value in USD (null if unpriced).
        net_usd_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Net Usd Value
          description: Net position value in USD (collateral - debt); null if unpriced.
        leverage:
          anyOf:
            - type: string
            - type: 'null'
          title: Leverage
          description: >-
            Leverage multiplier: collateral_usd / (collateral_usd - debt_usd).
            Null when unpriced or net value is non-positive.
        health_factor:
          anyOf:
            - type: string
            - type: 'null'
          title: Health Factor
          description: >-
            Health factor. Above 1 is safe; below 1 risks liquidation. See
            health_factor_scope for what it covers.
        health_factor_scope:
          type: string
          enum:
            - market
            - account
          title: Health Factor Scope
          description: >-
            'market' for Morpho (isolated per-market health). 'account' for
            Aave: collateral is pooled, so all collateral backs all debt and
            this health factor is shared by every Aave position on the account —
            see aave_account_summary for the account-level figures.
      additionalProperties: false
      type: object
      required:
        - collateral_amount
        - debt_amount
        - health_factor_scope
      title: LoopedPositionCurrentState
      description: Live on-chain state of an OPEN looped position.
    LoopedPositionTotals:
      properties:
        total_collateral_added:
          type: string
          title: Total Collateral Added
          description: Total collateral added over the position's lifetime.
        total_collateral_removed:
          type: string
          title: Total Collateral Removed
          description: Total collateral removed over the position's lifetime.
        total_debt_added:
          type: string
          title: Total Debt Added
          description: Total debt borrowed over the position's lifetime.
        total_debt_removed:
          type: string
          title: Total Debt Removed
          description: Total debt repaid over the position's lifetime.
        loop_tx_count:
          type: integer
          title: Loop Tx Count
          description: Number of loop_open + loop_increase transactions.
        unwind_tx_count:
          type: integer
          title: Unwind Tx Count
          description: Number of unwind transactions.
        liquidation_count:
          type: integer
          title: Liquidation Count
          description: Number of liquidation events.
      additionalProperties: false
      type: object
      required:
        - total_collateral_added
        - total_collateral_removed
        - total_debt_added
        - total_debt_removed
        - loop_tx_count
        - unwind_tx_count
        - liquidation_count
      title: LoopedPositionTotals
      description: Lifetime totals across all of a looped position's transactions.
    LoopedPositionHistoryEntry:
      properties:
        transaction_hash:
          type: string
          title: Transaction Hash
          description: Transaction hash.
        block_number:
          type: integer
          title: Block Number
          description: Block number of the transaction.
        block_timestamp:
          type: string
          format: date-time
          title: Block Timestamp
          description: Timestamp of the transaction.
        classification:
          type: string
          enum:
            - loop_open
            - loop_increase
            - unwind
            - supply
            - withdraw
            - borrow
            - repay
            - liquidation
            - mixed
          title: Classification
          description: >-
            What this transaction did to the position: loop_open / loop_increase
            (lever up with a swap), unwind (delever), single-sided
            supply/withdraw/borrow/repay, liquidation, or mixed.
        iterations:
          anyOf:
            - type: integer
            - type: 'null'
          title: Iterations
          description: >-
            Loop transactions only: number of borrow legs in this transaction
            (one per loop iteration). Null for non-loop transactions.
        collateral_delta:
          type: string
          title: Collateral Delta
          description: Signed change in collateral in this transaction (positive = added).
        debt_delta:
          type: string
          title: Debt Delta
          description: Signed change in debt in this transaction (positive = borrowed).
        swap:
          anyOf:
            - $ref: '#/components/schemas/SwapInfo'
            - type: 'null'
          description: The swap leg detected in this transaction, if any.
        events:
          items:
            $ref: '#/components/schemas/CreditEvent'
          type: array
          title: Events
          description: >-
            The raw lending events that make up this transaction (Morpho
            supply_collateral maps to 'supply', withdraw_collateral to
            'withdraw').
          default: []
      additionalProperties: false
      type: object
      required:
        - transaction_hash
        - block_number
        - block_timestamp
        - classification
        - collateral_delta
        - debt_delta
      title: LoopedPositionHistoryEntry
      description: One transaction in a looped position's lifetime.
    SwapInfo:
      properties:
        sold_token:
          type: string
          title: Sold Token
          description: Token sold in the swap (the borrowed/debt token).
        sold_symbol:
          type: string
          title: Sold Symbol
          description: Symbol of the sold token.
        sold_amount:
          type: string
          title: Sold Amount
          description: Amount of the sold token.
        bought_token:
          type: string
          title: Bought Token
          description: Token bought in the swap (the collateral token).
        bought_symbol:
          type: string
          title: Bought Symbol
          description: Symbol of the bought token.
        bought_amount:
          type: string
          title: Bought Amount
          description: Amount of the bought token.
        router:
          anyOf:
            - type: string
            - type: 'null'
          title: Router
          description: >-
            The outbound counterparty when it is the 1inch aggregation router.
            Null when the swap settled from an executor contract (informational
            only — never required to detect the swap).
      additionalProperties: false
      type: object
      required:
        - sold_token
        - sold_symbol
        - sold_amount
        - bought_token
        - bought_symbol
        - bought_amount
      title: SwapInfo
      description: >-
        The DEX swap leg detected inside a loop transaction.


        Evidence is token-filtered and executor-proof: the sold (debt) token
        left the

        account to a non-protocol counterparty and the bought (collateral) token

        arrived from a non-protocol counterparty. 1inch fills often settle from
        an

        executor contract, so the router is recorded only when it happens to be
        the

        outbound counterparty — it is never required for detection.
    CreditEvent:
      properties:
        event_type:
          type: string
          enum:
            - supply
            - withdraw
            - borrow
            - repay
            - liquidation
            - transfer_in
            - transfer_out
          title: Event Type
          description: Type of credit event.
        block_number:
          type: integer
          title: Block Number
          description: Block number when the event occurred
        block_timestamp:
          type: string
          format: date-time
          title: Block Timestamp
          description: Timestamp when the event occurred
        transaction_hash:
          type: string
          title: Transaction Hash
          description: Transaction hash of the event
        amount:
          type: string
          title: Amount
          description: Amount involved in the event
        symbol:
          type: string
          title: Symbol
          description: Symbol of the token
      type: object
      required:
        - event_type
        - block_number
        - block_timestamp
        - transaction_hash
        - amount
        - symbol
      title: CreditEvent
      description: A single historical event in a credit position.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````