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

# On-chain holdings with cost-basis overlay

> Returns the wallet's current on-chain SPL token holdings sourced from Shyft's `all_tokens` API, with FIFO cost-basis and unrealized PnL overlaid where Dexploit has swap history.

Tokens acquired via airdrop or off-platform transfers will appear with `no_cost_basis: true` and `cost_basis_sol: null`.

When Shyft is temporarily unavailable the endpoint degrades to FIFO-derived holdings and sets `holdings_source: "fifo_fallback"` — it never returns 5xx on a Shyft outage.

Response is cached 30 seconds per wallet. See [Wallet portfolio](/concepts/wallet-portfolio) for a full explanation of the two holdings sources.



## OpenAPI

````yaml /api-reference/openapi.json get /wallets/{w}/holdings
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}/holdings:
    get:
      tags:
        - Wallet portfolio
      summary: On-chain holdings with cost-basis overlay
      description: >-
        Returns the wallet's current on-chain SPL token holdings sourced from
        Shyft's `all_tokens` API, with FIFO cost-basis and unrealized PnL
        overlaid where Dexploit has swap history.


        Tokens acquired via airdrop or off-platform transfers will appear with
        `no_cost_basis: true` and `cost_basis_sol: null`.


        When Shyft is temporarily unavailable the endpoint degrades to
        FIFO-derived holdings and sets `holdings_source: "fifo_fallback"` — it
        never returns 5xx on a Shyft outage.


        Response is cached 30 seconds per wallet. See [Wallet
        portfolio](/concepts/wallet-portfolio) for a full explanation of the two
        holdings sources.
      operationId: getWalletHoldings
      parameters:
        - name: w
          in: path
          required: true
          schema:
            type: string
          description: Wallet address (base58, 32–44 characters).
        - name: dex
          in: query
          required: false
          schema:
            type: integer
          description: >-
            Filter FIFO cost-basis computation to a single DEX by integer ID.
            See `DexId` for the mapping. Has no effect on the Shyft on-chain
            token list.
      responses:
        '200':
          description: Holdings with cost-basis
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HoldingsResponse'
        '400':
          description: Wallet address is not valid base58
          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:
    HoldingsResponse:
      type: object
      description: >-
        Response from `/wallets/{w}/holdings`. `holdings_source` indicates
        whether the token list came from Shyft (authoritative) or fell back to
        FIFO-derived data.
      required:
        - wallet
        - holdings_source
        - holdings
        - computed_at
      properties:
        wallet:
          type: string
        holdings_source:
          type: string
          enum:
            - shyft
            - fifo_fallback
          description: >-
            `shyft` = authoritative on-chain balances. `fifo_fallback` = Shyft
            was temporarily unavailable; list is derived from Dexploit's swap
            index only.
        holdings:
          type: array
          items:
            $ref: '#/components/schemas/Holding'
        computed_at:
          type: integer
          format: int64
          description: Unix epoch milliseconds when this response was assembled.
    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
    Holding:
      type: object
      description: >-
        One token position in a wallet holdings response. `cost_basis_sol`,
        `unrealized_pnl_sol`, and `current_value_usd` are `null` when not
        computable (see `no_cost_basis` and `price_stale`).
      required:
        - mint
        - qty
        - no_cost_basis
        - price_stale
      properties:
        mint:
          type: string
          description: Token mint address (base58).
        qty:
          type: integer
          format: int64
          description: Current quantity in token base units.
        cost_basis_sol:
          type:
            - number
            - 'null'
          description: >-
            FIFO average cost in SOL, scaled to the current on-chain qty. `null`
            when no swap history is available for this mint.
        no_cost_basis:
          type: boolean
          description: >-
            `true` when the mint has no swap history in Dexploit's index
            (airdrop, off-platform transfer, etc.).
        current_value_sol:
          type:
            - number
            - 'null'
          description: >-
            Current market value in SOL (latest candle price × qty). `null` when
            price is unavailable.
        current_value_usd:
          type:
            - number
            - 'null'
          description: >-
            Current market value in USD via the Pyth SOL/USD oracle. `null` when
            price or oracle is unavailable.
        unrealized_pnl_sol:
          type:
            - number
            - 'null'
          description: >-
            `current_value_sol − cost_basis_sol`. `null` when either value is
            unavailable.
        price_stale:
          type: boolean
          description: >-
            `true` when no recent candle price was found for this mint (no trade
            in the last hour).
  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.

````