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

# User trades

> User's perp and spot trade fills. Each trade row carries `asset_type`. Spot rows use `action` values `Buy` or `Sell`, leave `client_order_id` empty, and zero `realized_pnl_amount`, `realized_funding_amount`, and `fee_amount` because spot has no positions/funding and per-side fee attribution is unavailable.



## AsyncAPI

````yaml api-reference/asyncapi.json userTrades
id: userTrades
title: User trades
description: >-
  User's perp and spot trade fills. Each trade row carries `asset_type`. Spot
  rows use `action` values `Buy` or `Sell`, leave `client_order_id` empty, and
  zero `realized_pnl_amount`, `realized_funding_amount`, and `fee_amount`
  because spot has no positions/funding and per-side fee attribution is
  unavailable.
servers:
  - id: testnet
    protocol: wss
    host: api.testnet.aptoslabs.com/decibel/ws
    bindings: []
    variables: []
address: user_trades:{userAddr}
parameters:
  - id: userAddr
    jsonSchema:
      type: string
      description: User wallet address (Aptos address format, e.g. 0x123...)
    description: User wallet address (Aptos address format, e.g. 0x123...)
    type: string
    required: true
    deprecated: false
bindings: []
operations:
  - &ref_1
    id: receiveuserTrades
    title: Receiveuser trades
    description: >-
      Receive updates for user's perp and spot trade fills. each trade row
      carries `asset_type`. spot rows use `action` values `buy` or `sell`, leave
      `client_order_id` empty, and zero `realized_pnl_amount`,
      `realized_funding_amount`, and `fee_amount` because spot has no
      positions/funding and per-side fee attribution is unavailable.
    type: receive
    messages:
      - &ref_2
        id: UserTradesMessage
        payload:
          - name: UserTradesMessage
            description: >-
              User's perp and spot trade fills. Each trade row carries
              `asset_type`. Spot rows use `action` values `Buy` or `Sell`, leave
              `client_order_id` empty, and zero `realized_pnl_amount`,
              `realized_funding_amount`, and `fee_amount` because spot has no
              positions/funding and per-side fee attribution is unavailable.
            type: object
            properties:
              - name: topic
                type: string
                required: true
              - name: trades
                type: array
                required: true
                properties:
                  - name: account
                    type: string
                    description: User's account address
                    required: true
                  - name: action
                    type: string
                    description: >-
                      Trade action type. Perp: position-centric ("OpenLong",
                      "CloseShort",

                      "Net", ...). Spot: side from this row's perspective ("Buy"
                      / "Sell").
                    required: true
                  - name: asset_type
                    type: string
                    description: >-
                      Discriminator carried on DTOs that can mix perp and spot
                      rows (markets,

                      orders, trades, bulk orders, bulk order fills, and
                      WebSocket payloads).

                      Also accepted as a query parameter on REST endpoints that
                      can filter to one

                      product.


                      Wire format is lowercase (`"perp"` / `"spot"`) and
                      accepted

                      case-insensitively on the request side via
                      [`impl_case_insensitive_deserialize`].
                    enumValues:
                      - perp
                      - spot
                    required: true
                  - name: client_order_id
                    type: string
                    description: Client-specified order ID
                    required: true
                  - name: counter_party_account
                    type: string
                    description: >-
                      Counter party account on the other leg of the fill. For
                      liquidation /

                      ADL / delisting fills this is the backstop liquidator.
                      Empty string for

                      pre-V2 historical trades that did not carry counter party
                      on-chain.
                    required: true
                  - name: fee_amount
                    type: number
                    description: >-
                      Fee paid by this row's account, normalized. Perp: always
                      in the

                      collateral asset (USDC). Spot: charged in the asset this
                      side

                      RECEIVED (protocol + builder fee combined); see
                      `fee_asset`.
                    required: true
                  - name: fee_asset
                    type: &ref_0
                      - string
                      - 'null'
                    description: >-
                      FA metadata address of the asset `fee_amount` is
                      denominated in.

                      Spot only (base asset for the buyer, quote for the
                      seller); absent

                      for perp rows, where the fee is implicitly the collateral
                      asset.
                    required: false
                  - name: is_profit
                    type: boolean
                    description: Whether trade was profitable
                    required: true
                  - name: is_rebate
                    type: boolean
                    description: Whether trade received rebate
                    required: true
                  - name: market
                    type: string
                    description: Market identifier address
                    required: true
                  - name: order_id
                    type: string
                    description: Order ID associated with trade
                    required: true
                  - name: price
                    type: number
                    description: Trade price
                    required: true
                  - name: realized_funding_amount
                    type: number
                    description: >-
                      Realized funding amount in USDC

                      - Negative value: trader PAID funding (e.g., long position
                      with positive funding rate)

                      - Positive value: trader RECEIVED funding (e.g., short
                      position with positive funding rate)

                      - Zero: no funding accrued
                    required: true
                  - name: realized_pnl_amount
                    type: number
                    description: Realized PnL amount
                    required: true
                  - name: size
                    type: number
                    description: Trade size
                    required: true
                  - name: source
                    type: string
                    description: >-
                      Trade source (e.g., "OrderFill", "MarginCall",
                      "BackStopLiquidation", "ADL", "MarketDelisted")
                    required: true
                  - name: trade_id
                    type: string
                    description: Trade ID
                    required: true
                  - name: transaction_unix_ms
                    type: integer
                    description: Transaction timestamp in milliseconds
                    required: true
                  - name: transaction_version
                    type: integer
                    description: Transaction version
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - topic
            - trades
          properties:
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-275>
            trades:
              type: array
              items:
                type: object
                required:
                  - asset_type
                  - account
                  - market
                  - action
                  - source
                  - trade_id
                  - size
                  - price
                  - is_profit
                  - realized_pnl_amount
                  - realized_funding_amount
                  - is_rebate
                  - fee_amount
                  - order_id
                  - client_order_id
                  - transaction_unix_ms
                  - transaction_version
                  - counter_party_account
                properties:
                  account:
                    type: string
                    description: User's account address
                    example: '0x1234567890abcdef1234567890abcdef12345678'
                    x-parser-schema-id: <anonymous-schema-192>
                  action:
                    type: string
                    description: >-
                      Trade action type. Perp: position-centric ("OpenLong",
                      "CloseShort",

                      "Net", ...). Spot: side from this row's perspective ("Buy"
                      / "Sell").
                    example: buy
                    x-parser-schema-id: <anonymous-schema-193>
                  asset_type:
                    type: string
                    description: >-
                      Discriminator carried on DTOs that can mix perp and spot
                      rows (markets,

                      orders, trades, bulk orders, bulk order fills, and
                      WebSocket payloads).

                      Also accepted as a query parameter on REST endpoints that
                      can filter to one

                      product.


                      Wire format is lowercase (`"perp"` / `"spot"`) and
                      accepted

                      case-insensitively on the request side via
                      [`impl_case_insensitive_deserialize`].
                    enum:
                      - perp
                      - spot
                    x-parser-schema-id: AssetType
                  client_order_id:
                    type: string
                    description: Client-specified order ID
                    example: client_order_abc
                    x-parser-schema-id: <anonymous-schema-194>
                  counter_party_account:
                    type: string
                    description: >-
                      Counter party account on the other leg of the fill. For
                      liquidation /

                      ADL / delisting fills this is the backstop liquidator.
                      Empty string for

                      pre-V2 historical trades that did not carry counter party
                      on-chain.
                    example: >-
                      0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210
                    x-parser-schema-id: <anonymous-schema-195>
                  fee_amount:
                    type: number
                    format: double
                    description: >-
                      Fee paid by this row's account, normalized. Perp: always
                      in the

                      collateral asset (USDC). Spot: charged in the asset this
                      side

                      RECEIVED (protocol + builder fee combined); see
                      `fee_asset`.
                    x-parser-schema-id: <anonymous-schema-196>
                  fee_asset:
                    type: *ref_0
                    description: >-
                      FA metadata address of the asset `fee_amount` is
                      denominated in.

                      Spot only (base asset for the buyer, quote for the
                      seller); absent

                      for perp rows, where the fee is implicitly the collateral
                      asset.
                    x-parser-schema-id: <anonymous-schema-197>
                  is_profit:
                    type: boolean
                    description: Whether trade was profitable
                    x-parser-schema-id: <anonymous-schema-198>
                  is_rebate:
                    type: boolean
                    description: Whether trade received rebate
                    x-parser-schema-id: <anonymous-schema-199>
                  market:
                    type: string
                    description: Market identifier address
                    example: 0xmarket123456789abcdef
                    x-parser-schema-id: <anonymous-schema-200>
                  order_id:
                    type: string
                    description: Order ID associated with trade
                    example: '12345'
                    x-parser-schema-id: <anonymous-schema-201>
                  price:
                    type: number
                    format: double
                    description: Trade price
                    example: 50000.25
                    x-parser-schema-id: <anonymous-schema-202>
                  realized_funding_amount:
                    type: number
                    format: double
                    description: >-
                      Realized funding amount in USDC

                      - Negative value: trader PAID funding (e.g., long position
                      with positive funding rate)

                      - Positive value: trader RECEIVED funding (e.g., short
                      position with positive funding rate)

                      - Zero: no funding accrued
                    example: -15.5
                    x-parser-schema-id: <anonymous-schema-203>
                  realized_pnl_amount:
                    type: number
                    format: double
                    description: Realized PnL amount
                    x-parser-schema-id: <anonymous-schema-204>
                  size:
                    type: number
                    format: double
                    description: Trade size
                    example: 100.5
                    x-parser-schema-id: <anonymous-schema-205>
                  source:
                    type: string
                    description: >-
                      Trade source (e.g., "OrderFill", "MarginCall",
                      "BackStopLiquidation", "ADL", "MarketDelisted")
                    example: OrderFill
                    x-parser-schema-id: <anonymous-schema-206>
                  trade_id:
                    type: string
                    description: Trade ID
                    example: '3647276'
                    x-parser-schema-id: <anonymous-schema-207>
                  transaction_unix_ms:
                    type: integer
                    format: int64
                    description: Transaction timestamp in milliseconds
                    example: 1634567890000
                    x-parser-schema-id: <anonymous-schema-208>
                  transaction_version:
                    type: integer
                    format: int64
                    description: Transaction version
                    example: 3647276285
                    minimum: 0
                    x-parser-schema-id: <anonymous-schema-209>
                x-parser-schema-id: TradeDto
              x-parser-schema-id: <anonymous-schema-276>
          x-parser-schema-id: UserTradesResponse
        title: User trades message
        description: >-
          User's perp and spot trade fills. Each trade row carries `asset_type`.
          Spot rows use `action` values `Buy` or `Sell`, leave `client_order_id`
          empty, and zero `realized_pnl_amount`, `realized_funding_amount`, and
          `fee_amount` because spot has no positions/funding and per-side fee
          attribution is unavailable.
        example: |-
          {
            "topic": "user_trades:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
            "trades": [
              {
                "asset_type": "perp",
                "account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                "action": "Open Long",
                "source": "OrderFill",
                "trade_id": "3647276",
                "size": 1.5,
                "price": 50125.75,
                "is_profit": true,
                "realized_pnl_amount": 187.5,
                "realized_funding_amount": -12.3,
                "is_rebate": true,
                "fee_amount": 25.06,
                "order_id": "45678",
                "client_order_id": "order_123",
                "transaction_unix_ms": 1699564800000,
                "transaction_version": 3647276285,
                "counter_party_account": "0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210"
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: UserTradesMessage
          - id: x-parser-message-name
            value: UserTradesMessage
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: userTrades
sendOperations:
  - *ref_1
receiveOperations: []
sendMessages:
  - *ref_2
receiveMessages: []
extensions:
  - id: x-parser-unique-object-id
    value: userTrades
securitySchemes: []

````