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

# Wallet cost-basis PnL summary

> Phase 8 cost-basis PnL summary for a wallet: realized + read-time-spot unrealized SOL, open/closed position counts, USD via Pyth, and a compact per-position list. Empty wallets return zeros and an empty `positions` array.

Cached 5s when any position traded in the last 5 minutes, otherwise 30s.



## OpenAPI

````yaml /api-reference/openapi.json get /v2/pnl/wallets/{wallet}
openapi: 3.1.0
info:
  title: Dexploit API
  version: 1.0.0
  description: Real-time and historical Solana DEX swap and OHLCV data.
servers:
  - url: https://api.dexploit.dev
    description: Production
security:
  - ApiKeyHeader: []
  - BearerAuth: []
  - ApiKeyQuery: []
paths:
  /v2/pnl/wallets/{wallet}:
    get:
      tags:
        - Wallet PnL (v2)
      summary: Wallet cost-basis PnL summary
      description: >-
        Phase 8 cost-basis PnL summary for a wallet: realized + read-time-spot
        unrealized SOL, open/closed position counts, USD via Pyth, and a compact
        per-position list. Empty wallets return zeros and an empty `positions`
        array.


        Cached 5s when any position traded in the last 5 minutes, otherwise 30s.
      operationId: getPnlV2Wallet
      parameters:
        - name: wallet
          in: path
          required: true
          schema:
            type: string
          description: Wallet address (base58, 32–44 characters).
        - name: pnl_mode
          in: query
          required: false
          schema:
            type: string
            enum:
              - raw
              - strict
              - adjusted
            default: adjusted
          description: >-
            PnL accounting mode. `strict` (FIFO) and `adjusted` (weighted-avg
            cost) are realized-PnL figures; `raw` is **net cash-flow** (Σ sells
            − Σ buys), not realized PnL. Unknown values fall back to `adjusted`.
      responses:
        '200':
          description: PnL summary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnlV2Summary'
        '400':
          description: Invalid parameter or malformed body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    PnlV2Summary:
      type: object
      description: >-
        Cost-basis PnL summary for a wallet (Phase 8 engine). All `*_sol` fields
        are SOL. `unrealized_sol` is read-time spot Σ(price−avg_cost)*balance;
        null-priced mints contribute 0. Wallets with no positions return zeros
        and an empty `positions` array.
      properties:
        wallet:
          type: string
        pnl_mode:
          type: string
        realized_sol:
          type: number
        unrealized_sol:
          type: number
          description: Read-time spot unrealized PnL (null-priced mints contribute 0).
        cost_basis_sol:
          type: number
        open_positions:
          type: integer
          description: Count of positions with balance > 0 and not a quote mint.
        closed_positions:
          type: integer
          description: Count of positions with balance == 0.
        realized_usd:
          type:
            - number
            - 'null'
        unrealized_usd:
          type:
            - number
            - 'null'
        oracle:
          $ref: '#/components/schemas/OracleSnapshot'
        positions:
          type: array
          description: Compact per-position rows.
          items:
            type: object
            properties:
              mint:
                type: string
              balance_atomic:
                type: integer
              realized_sol:
                type: number
              unrealized_sol:
                type:
                  - number
                  - 'null'
              is_arbitrageur:
                type: boolean
    ErrorEnvelope:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: INVALID_PARAM
            message:
              type: string
              example: >-
                use pair_address; see /api/v1/pairs?token_address=X to discover
                pools
    OracleSnapshot:
      type:
        - object
        - 'null'
      description: >-
        Pyth SOL/USD oracle snapshot used for USD conversion. `null` when the
        oracle is unavailable.
      properties:
        price:
          type: number
          description: SOL/USD price.
        confidence:
          type: number
          description: Pyth confidence interval around `price`.
        published_at:
          type: integer
          description: Oracle publish time (Unix epoch seconds).
        source:
          type: string
          description: Oracle source identifier (e.g. `pyth`).
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Preferred for swaps-api endpoints (`/swaps/*`, `/stats/*`, `/trending`,
        `/pool-events`).
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Required by the OHLCV endpoints (`/api/v1/*`) and accepted by every
        other endpoint. Send `Authorization: Bearer ohlcv_live_sk_<your_key>`.
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: >-
        Browser-friendly alternative to the Bearer header — accepted by every
        endpoint and required for WebSocket from the browser.

````