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

# Get wallet set PnL

> Realized and unrealized PnL across an EVM and Solana address combined, FIFO-based.



## OpenAPI

````yaml /openapi-v1.yaml get /v1/wallet-sets/pnl
openapi: 3.0.3
info:
  version: 1.0.0
  title: REST API
  description: REST-like API provides access to rich Zerion ecosystem.
  contact:
    name: Zerion API
    url: https://developers.zerion.io/
    email: api@zerion.io
servers:
  - description: Production API
    url: https://api.zerion.io
security:
  - APIKeyBasicAuth: []
tags:
  - name: wallets
    description: >-
      Operations related to wallets, such as portfolio charts, positions, and
      transactions.
  - name: wallet sets
    description: >-
      Operations on a wallet set, returning aggregated portfolio data across at
      most one EVM address and one Solana address queried together.
  - name: fungibles
    description: >-
      Operations related to fungible assets, such as list them all, search or
      get by ID.
  - name: chains
    description: Operations related to chains, such as list all chains.
  - name: swap
    description: Operations related to swapping and bridging assets.
  - name: gas
    description: Operations related to gas.
  - name: nfts
    description: >-
      Operations related to non fungible assets, such list them, search or get
      by ID.
  - name: dapps
    description: >-
      Operations related to decentralized applications, such as list them all,
      search or get by ID.
  - name: subscriptions to transactions
    description: Operations related to subscriptions to transactions.
paths:
  /v1/wallet-sets/pnl:
    get:
      tags:
        - wallet sets
      summary: Get wallet set PnL
      description: >
        Returns a wallet set's profit and loss (PnL): unrealized PnL, realized
        PnL and net invested amounts, with filters for asset categories such as
        NFTs. Calculations use FIFO (first in, first out). A wallet set is one
        EVM address, one Solana address, or both. At least one is required.


        The first request for a wallet set can return `503`. Retry it later:
        only the `503` carries a `Retry-After` header.


        Addresses Zerion doesn't track return `400`. That covers contract
        addresses that aren't smart-contract wallets. Safe and ERC-4337 accounts
        work as normal.


        The 1 million action limit applies per address. If any address in the
        set is over it, the request returns `422` once the limit is detected.
      operationId: getWalletSetPNL
      parameters:
        - $ref: '#/components/parameters/WalletSetAddresses'
        - $ref: '#/components/parameters/Currency'
        - name: filter[chain_ids]
          in: query
          style: form
          explode: false
          description: >-
            Calculate PnL only for specified chains (comma-separated list). Only
            chains reporting both `supports_transactions` and
            `supports_positions` in the `flags` of `GET /v1/chains/` are
            accepted here. Naming a chain that fails that gate returns `400`
            rather than an empty result, with `detail` reading `chain <id> does
            not support PnL` (for example `chain bob does not support PnL`). A
            chain of the wrong network family for the wallet set's addresses is
            rejected the same way, with `does not support this wallet address
            type`. When the filter is omitted, chains that fail the gate are
            left out of `data` silently, with no error and no `meta` signal.
          schema:
            type: array
            example:
              - ethereum
              - polygon
            maxItems: 25
            items:
              type: string
        - name: filter[fungible_ids]
          in: query
          style: form
          explode: false
          description: >
            Calculate PnL only for these fungible IDs (comma-separated list, up
            to 100).


            With `filter[fungible_ids]` or `filter[fungible_implementations]`,
            assets without a price are left out of the calculation instead of
            causing an error. The excluded assets are listed in the response
            metadata.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
              maxLength: 44
        - name: filter[fungible_implementations]
          in: query
          style: form
          explode: false
          description: >
            Calculate PnL only for these token implementations (comma-separated
            list of `chain_id:address` pairs, up to 100).


            For example:
            `base:0xae16c445d8a4082cecb49a9465e4dd5499df947d,ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48`


            With `filter[fungible_ids]` or `filter[fungible_implementations]`,
            assets without a price are left out of the calculation instead of
            causing an error. The excluded assets are listed in the response
            metadata.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: since
          in: query
          required: false
          description: >
            Count only sales since this time, as a Unix timestamp in
            milliseconds.


            **Note:** PnL is pre-computed at standard marks (`now`, `1 day ago`,
            `1 week ago`, `1 month ago`, `1 year ago`, `beginning of the year`).
            Other values are supported only if fewer than 3,000 transactions sit
            between your timestamp and the nearest mark. Otherwise the request
            errors out.
          schema:
            type: string
            example: '1688842525735'
            minLength: 13
            maxLength: 13
        - name: till
          in: query
          required: false
          description: >
            Count only sales until this time, as a Unix timestamp in
            milliseconds.


            **Note:** PnL is pre-computed at standard marks (`now`, `1 day ago`,
            `1 week ago`, `1 month ago`, `1 year ago`, `beginning of the year`).
            Other values are supported only if fewer than 3,000 transactions sit
            between your timestamp and the nearest mark. Otherwise the request
            errors out.
          schema:
            type: string
            example: '1688842525735'
            minLength: 13
            maxLength: 13
      responses:
        '200':
          $ref: '#/components/responses/PNLResponse-2'
        '400':
          $ref: '#/components/responses/MalformedParameters'
        '401':
          $ref: '#/components/responses/UnauthenticatedError'
        '422':
          $ref: '#/components/responses/QueryNotSupported'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          $ref: '#/components/responses/RetryAfter'
components:
  parameters:
    WalletSetAddresses:
      name: addresses
      in: query
      required: true
      style: form
      explode: false
      description: >
        A list of wallet addresses forming a wallet set.

        example:
        0x42b9df65b219b3dd36ff330a4dd8f327a6ada990,8BH9pjtgyZDC4iAQH5ZiYDZ1MDWC98xki2V8NzqqKW3K


        The set must contain at least one address and may include at most one
        address per supported chain type (currently EVM and Solana).

        The order of addresses does not matter.


        Returns 400 if an address in the set is not one Zerion tracks, such as a
        token contract, router

        or exchange hot wallet.
      schema:
        type: array
        minItems: 1
        maxItems: 2
        items:
          type: string
    Currency:
      name: currency
      in: query
      required: false
      description: Denominated currency value of returned prices
      schema:
        type: string
        default: usd
        enum:
          - eth
          - btc
          - usd
          - eur
          - krw
          - rub
          - gbp
          - aud
          - cad
          - inr
          - jpy
          - nzd
          - try
          - zar
          - cny
          - chf
  responses:
    PNLResponse-2:
      description: Response for requested wallet set PnL
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Response-9'
    MalformedParameters:
      description: Parameters are malformed
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Parameter is malformed
                    detail:
                      type: string
                      description: Long description of the error
                      example: Some validation errors will be described here
    UnauthenticatedError:
      description: Unathenticated request
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Unauthorized Error
                    detail:
                      type: string
                      description: Long description of the error
                      example: >-
                        The API key is invalid, please, make sure that you are
                        using a valid key
    QueryNotSupported:
      description: >
        The request cannot be served and retrying will not change that.


        Unlike a `503`, this response carries no `Retry-After` header. Contact
        support if you

        need the request enabled.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: This request is not supported
                    detail:
                      type: string
                      description: Long description of the error
                      example: >-
                        This request cannot be processed, and retrying will not
                        help. Please contact support if you need it enabled.
    TooManyRequests:
      description: Too many requests error
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Too many requests
                    detail:
                      type: string
                      description: Long description of the error
                      example: Your request had been throttled
    RetryAfter:
      description: >
        Service is temporarily unavailable.


        A transient state: the data is being prepared. Retry after the delay
        given in the

        `Retry-After` header. Wallets with long histories can need several
        attempts.
      headers:
        Retry-After:
          description: >
            Indicates how long the client should wait before making a follow-up
            request.
          schema:
            type: integer
            example: 10
            description: Number of seconds to wait.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Service is temporarily unavailable
                    detail:
                      type: string
                      description: Long description of the error
                      example: Please, retry later (check the Retry-After header)
  schemas:
    Response-9:
      type: object
      required:
        - links
        - data
      properties:
        links:
          $ref: '#/components/schemas/ResponseLinks-9'
        data:
          $ref: '#/components/schemas/Container-12'
        meta:
          type: object
          description: >
            Metadata about the PnL calculation (only present when assets were
            excluded from the calculation).

            The structure matches the filter type used in the request:

            - When filtering by `fungible_ids`, the meta contains an
            `excluded_fungible_ids` array

            - When filtering by `fungible_implementations`, the meta contains an
            `excluded_fungible_implementations` array

            - If both filters are used, both fields may appear in the meta
          properties:
            excluded_fungible_ids:
              type: array
              items:
                type: string
              description: >-
                Fungible asset IDs that were excluded due to missing prices
                (only present when the request used fungible_ids filter)
              example:
                - 4a702a34-5cfd-41af-96ad-bd1c45c3672e
            excluded_fungible_implementations:
              type: array
              items:
                type: string
              description: >
                Asset implementations that were excluded due to missing prices
                (only present when the request used fungible_implementations
                filter).

                Format matches the user's query format: "chain:address" for
                regular tokens, "chain:" for base assets.
              example:
                - ethereum:0x6b175474e89094c44da98b954eedeac495271d0f
                - 'ethereum:'
    ResponseLinks-9:
      type: object
      required:
        - self
      properties:
        self:
          type: string
          format: url
          example: >-
            https://api.zerion.io/v1/wallet-sets/pnl?addresses=0x42b9df65b219b3dd36ff330a4dd8f327a6ada990%2C8BH9pjtgyZDC4iAQH5ZiYDZ1MDWC98xki2V8NzqqKW3K&currency=eth&filter%5Bchain_ids%5D=ethereum%2Csolana&filter%5Bfungible_ids%5D=11111111111111111111111111111111%2Ceth
    Container-12:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          description: Resource type
          enum:
            - pnl
        id:
          type: string
          description: Wallet set PNL unique ID
          example: >-
            0x42b9df65b219b3dd36ff330a4dd8f327a6ada990,8BH9pjtgyZDC4iAQH5ZiYDZ1MDWC98xki2V8NzqqKW3K
        attributes:
          $ref: '#/components/schemas/Attributes-2'
    Attributes-2:
      type: object
      properties:
        total_gain:
          type: number
          format: float
          description: >
            Total Gain.


            The sum of realized and unrealized gains across all fungible assets,
            calculated using the FIFO (First In, First Out) method.
          example: -637.8173517
        realized_gain:
          type: number
          format: float
          description: >
            Realized Gain.


            The gain (or loss) realized from the sale of fungible assets,
            calculated using the FIFO (First In, First Out) method (the

            earliest purchases are matched with the earliest sales).

            The cost basis of the oldest assets is subtracted from the sale
            proceeds.
          example: -655.3618983
        unrealized_gain:
          type: number
          format: float
          description: >
            Unrealized Gain.


            The potential gain (or loss) on unsold fungible assets, calculated
            as the difference between their current market value and cost basis
            using the FIFO method (the

            earliest purchases are matched with the earliest sales).
          example: 17.5445466
        relative_total_gain_percentage:
          type: number
          format: float
          description: >
            Relative Total Gain Percentage.


            The percentage return on total investment, combining both realized
            and unrealized gains.
          example: -11.38
        relative_realized_gain_percentage:
          type: number
          format: float
          description: >
            Relative Realized Gain Percentage.


            The percentage return on realized trades, calculated as realized
            gain divided by realized cost basis.
          example: -15.15
        relative_unrealized_gain_percentage:
          type: number
          format: float
          description: >
            Relative Unrealized Gain Percentage.


            The percentage return on open positions, calculated as unrealized
            gain divided by the current cost basis of held assets.
          example: -0.19
        total_fee:
          type: number
          format: float
          description: |
            Total Fees Paid.

            The sum of all transaction fees associated with asset trades.
          example: 281.9088917
        total_invested:
          type: number
          format: float
          description: >
            Total Invested Amount.


            The total amount invested in fungible assets (sum of all buy
            transactions), calculated using the FIFO method.
          example: 701.2
        realized_cost_basis:
          type: number
          format: float
          description: >
            Realized Cost Basis.


            The cost basis of closed (sold) positions, calculated using the FIFO
            method.
          example: 655.36
        net_invested:
          type: number
          format: float
          description: >
            Net Invested Amount.


            The total amount invested in fungible assets that have not been
            sold, calculated using the FIFO method (the earliest purchases are

            matched with the earliest sales).
          example: 45.84218703
        received_external:
          type: number
          format: float
          description: >
            Received Amount from Other Wallets.


            The cumulative value of all fungible assets received from other
            wallets.


            Note: This value does not include amounts traded internally within
            the wallet but does include `received_for_nfts`.
          example: 133971.2931
        sent_external:
          type: number
          format: float
          description: >
            Sent Amount to Other Wallets.


            The cumulative value of all fungible assets sent to other wallets.


            Note: This value does not include amounts traded internally within
            the wallet but does include `sent_for_nfts`.
          example: 133270.089
        sent_for_nfts:
          type: number
          format: float
          description: >
            Sent Amount for NFTs.


            The cumulative value of all fungible assets sent in transactions
            where the wallet receives NFTs.
          example: 133971.2931
        received_for_nfts:
          type: number
          format: float
          description: >
            Received Amount for NFTs.


            The cumulative value of all fungible assets received in transactions
            where the wallet sends NFTs.
          example: 133971.2931
        breakdown:
          $ref: '#/components/schemas/Breakdown'
    Breakdown:
      type: object
      description: >
        Detailed PnL breakdown by individual fungibles.

        Contains per-fungible statistics keyed either by fungible ID or by
        implementation (chain:address pair).

        Only returned when the request includes filters for fungibles
        (fungible_ids or fungible_implementations).
      properties:
        by_id:
          type: object
          description: PnL statistics broken down by fungible ID.
          additionalProperties:
            $ref: '#/components/schemas/Statistics'
          example:
            eth:
              average_buy_price: 1258.8
              average_sell_price: 1224.96
              total_gain: -6900.85
              realized_gain: -6871.21
              unrealized_gain: -29.64
              relative_total_gain_percentage: -11.38
              relative_realized_gain_percentage: -15.15
              relative_unrealized_gain_percentage: -0.19
              total_fee: 4679.93
              total_invested: 60643.33
              realized_cost_basis: 45363.2
              net_invested: 15280.13
              received_external: 35402.73
              sent_external: 22213.21
              sent_for_nfts: 1713.23
              received_for_nfts: 1635.05
        by_implementation:
          type: object
          description: >-
            PnL statistics broken down by fungible implementation (chain:address
            pair).
          additionalProperties:
            $ref: '#/components/schemas/Statistics'
          example:
            ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48:
              average_buy_price: 1
              average_sell_price: 1
              total_gain: 0
              realized_gain: 0
              unrealized_gain: 0
              relative_total_gain_percentage: 0
              relative_realized_gain_percentage: 0
              relative_unrealized_gain_percentage: 0
              total_fee: 12.5
              total_invested: 5000
              realized_cost_basis: 3000
              net_invested: 2000
              received_external: 1000
              sent_external: 500
              sent_for_nfts: 0
              received_for_nfts: 0
    Statistics:
      type: object
      description: PnL statistics for an individual fungible.
      properties:
        average_buy_price:
          type: number
          format: float
          description: The average price at which the fungible was purchased.
          example: 1258.8
        average_sell_price:
          type: number
          format: float
          description: The average price at which the fungible was sold.
          example: 1224.96
        total_gain:
          type: number
          format: float
          description: The sum of realized and unrealized gains for this fungible.
          example: -6900.85
        realized_gain:
          type: number
          format: float
          description: >-
            The gain (or loss) realized from selling this fungible, calculated
            using the FIFO method.
          example: -6871.21
        unrealized_gain:
          type: number
          format: float
          description: The potential gain (or loss) on unsold holdings of this fungible.
          example: -29.64
        relative_total_gain_percentage:
          type: number
          format: float
          description: The percentage return on total investment for this fungible.
          example: -11.38
        relative_realized_gain_percentage:
          type: number
          format: float
          description: The percentage return on realized trades for this fungible.
          example: -15.15
        relative_unrealized_gain_percentage:
          type: number
          format: float
          description: The percentage return on open positions for this fungible.
          example: -0.19
        total_fee:
          type: number
          format: float
          description: The sum of all transaction fees associated with this fungible.
          example: 4679.93
        total_invested:
          type: number
          format: float
          description: >-
            The total amount invested in this fungible (sum of all buy
            transactions).
          example: 60643.33
        realized_cost_basis:
          type: number
          format: float
          description: The cost basis of closed (sold) positions for this fungible.
          example: 45363.2
        net_invested:
          type: number
          format: float
          description: The total amount invested in this fungible that has not been sold.
          example: 15280.13
        received_external:
          type: number
          format: float
          description: The cumulative value of this fungible received from other wallets.
          example: 35402.73
        sent_external:
          type: number
          format: float
          description: The cumulative value of this fungible sent to other wallets.
          example: 22213.21
        sent_for_nfts:
          type: number
          format: float
          description: >-
            The cumulative value of this fungible sent in transactions where the
            wallet receives NFTs.
          example: 1713.23
        received_for_nfts:
          type: number
          format: float
          description: >-
            The cumulative value of this fungible received in transactions where
            the wallet sends NFTs.
          example: 1635.05
  securitySchemes:
    APIKeyBasicAuth:
      type: http
      scheme: basic
      description: >-
        To test endpoints here, paste your API key from the
        [Dashboard](https://dashboard.zerion.io/) into the username field and
        leave the password empty.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.