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

# FIFO realized and unrealized PnL

> Returns FIFO realized + unrealized PnL for the wallet over the specified window. Lot-based matching: buy lots pushed in time order, each sell matches against the earliest open lots and realizes `proceeds − cost_matched`.

The response always includes a `warning` field:

> `basic FIFO realized PnL; full cost-basis (cross-wallet, tax-lot, transfer-aware) ships in Phase 8`

This is intentional — FIFO is a good approximation for single-wallet trading but is not suitable for tax calculations or cross-wallet strategies. Full PnL ships in Phase 8.

Response cached 60 seconds.

See [Wallet portfolio](/concepts/wallet-portfolio#pnl-basic-fifo-realized-pnl).



## OpenAPI

````yaml /api-reference/openapi.json get /wallets/{w}/pnl/basic
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:
  /wallets/{w}/pnl/basic:
    get:
      tags:
        - Wallet portfolio
      summary: FIFO realized and unrealized PnL
      description: >-
        Returns FIFO realized + unrealized PnL for the wallet over the specified
        window. Lot-based matching: buy lots pushed in time order, each sell
        matches against the earliest open lots and realizes `proceeds −
        cost_matched`.


        The response always includes a `warning` field:


        > `basic FIFO realized PnL; full cost-basis (cross-wallet, tax-lot,
        transfer-aware) ships in Phase 8`


        This is intentional — FIFO is a good approximation for single-wallet
        trading but is not suitable for tax calculations or cross-wallet
        strategies. Full PnL ships in Phase 8.


        Response cached 60 seconds.


        See [Wallet
        portfolio](/concepts/wallet-portfolio#pnl-basic-fifo-realized-pnl).
      operationId: getWalletPnlBasic
      parameters:
        - name: w
          in: path
          required: true
          schema:
            type: string
          description: Wallet address (base58, 32–44 characters).
        - name: window
          in: query
          required: false
          schema:
            type: string
            enum:
              - 30d
              - 90d
              - 1y
              - all
            default: all
          description: Time window to compute PnL over.
        - name: dex
          in: query
          required: false
          schema:
            type: integer
          description: Filter to a single DEX by integer ID. See `DexId` for the mapping.
      responses:
        '200':
          description: FIFO PnL summary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnlBasicResponse'
        '400':
          description: Invalid parameter
          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:
    PnlBasicResponse:
      type: object
      description: >-
        FIFO realized + unrealized PnL for a wallet. Includes a `warning`
        pointing to Phase 8 for full multi-lot PnL.
      required:
        - wallet
        - window
        - realized_sol
        - unrealized_sol
        - total_volume_sol
        - win_rate
        - sell_count
        - warning
      properties:
        wallet:
          type: string
        window:
          type: string
          description: The time window used (`all`, `30d`, `90d`, `1y`).
        realized_sol:
          type: number
          description: Total FIFO realized PnL in SOL across all closed positions.
        unrealized_sol:
          type: number
          description: Unrealized PnL in SOL on remaining open lots.
        total_volume_sol:
          type: number
          description: Total SOL volume traded.
        win_rate:
          type: number
          description: Fraction of sells that were profitable (0.0–1.0).
        sell_count:
          type: integer
          description: Number of sell transactions included.
        realized_usd:
          type:
            - number
            - 'null'
          description: >-
            Realized PnL in USD via the Pyth oracle. `null` when oracle
            unavailable.
        unrealized_usd:
          type:
            - number
            - 'null'
          description: >-
            Unrealized PnL in USD via the Pyth oracle. `null` when oracle
            unavailable.
        oracle:
          type:
            - object
            - 'null'
          description: Pyth SOL/USD oracle snapshot used for USD conversion.
        warning:
          type: string
          description: >-
            Always present. Explains that this is basic FIFO PnL and that full
            cost-basis ships in Phase 8.
    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
  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.

````