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

# Risk Events

> Liquidation, margin settlement, and auto-deleveraging events for an account.

Track position liquidations, liquidation settlement, and auto-deleveraging on
the shared [account subscription](https://docs.bulk.trade/api-reference/ws-account.md). This reference
groups related messages; it does not create a separate subscription or a
network-side event filter. Dispatch received messages by `data.type`.

## Handling risk events

* `liquidation` reports the liquidated position's symbol, price, size, and fill
  direction (`isBuy`). `marginPrior` and `marginAfter` describe margin before
  and after liquidation; `reason` is optional human-readable context.
* `liquidationMargin` reports the separate margin-settlement leg. `loss` and
  `shortfall` describe the settlement outcome. Its transfers use integer
  `amountAtoms` in each asset's smallest units, not display-unit amounts.
  Isolated settlement events include `isoPubkey`.
* `adl` reports the auto-deleveraged position's symbol, price, size, and fill
  direction. Its optional `reason` provides human-readable context.

These events use nanosecond `timestamp` values. Preserve integer precision
when decoding them. Keep position events and settlement transfers distinct
when reconciling account activity.

For historical liquidation and ADL analysis, use
[`POST /account` with `type: "riskHistory"`](https://docs.bulk.trade/api-reference/getAccount#history-queries).


## AsyncAPI

````yaml api-reference/asyncapi.yaml account-risk
id: account-risk
title: Liquidation and ADL
description: >-
  Public read-only account subscription; no signature. This channel is a
  documentation view of selected messages, not a network-side event filter.
  Every view sends the same account subscription and the live connection can
  receive all account event types. Wait for accountSnapshot before treating
  account state as ready. Snapshot replaces state; identify positions by symbol
  and isoPubkey and subscribe to subaccounts separately. No replay cursor. Save
  the acknowledged topic for unsubscribe. Unsubscribe using the acknowledged
  topic; see [Connection Management](/api-reference/ws-connection#unsubscribe).
servers:
  - id: mainnet
    protocol: wss
    host: mainnet-ws1.bulk.trade
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: exchange-ws1.bulk.trade
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_1
    id: account-riskSubscribe
    title: Subscribe
    type: receive
    messages:
      - &ref_3
        id: subscribe
        contentType: application/json
        payload:
          - name: Subscribe
            description: >-
              Schema defaults on this request are playground example prefills,
              not omitted-field defaults accepted by the network endpoint.
            type: object
            properties:
              - name: method
                type: string
                enumValues:
                  - subscribe
                required: true
              - name: subscription
                type: array
                description: >-
                  Playground form template only. Paste an account public key
                  into user before sending; the blank value is not a valid
                  account and no account is preselected.
                required: true
                properties:
                  - name: type
                    type: string
                    enumValues:
                      - account
                    required: true
                  - name: user
                    type: oneOf
                    description: >-
                      Paste the account public key to observe. No account is
                      preselected.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            method:
              type: string
              enum:
                - subscribe
              default: subscribe
              x-parser-schema-id: <anonymous-schema-312>
            subscription:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - account
                    default: account
                    x-parser-schema-id: <anonymous-schema-315>
                  user:
                    oneOf:
                      - type: string
                        description: Account public key in base58.
                        x-parser-schema-id: <anonymous-schema-317>
                      - type: array
                        minItems: 1
                        items:
                          type: string
                          x-parser-schema-id: <anonymous-schema-319>
                        x-parser-schema-id: <anonymous-schema-318>
                    description: >-
                      Paste the account public key to observe. No account is
                      preselected.
                    x-parser-schema-id: <anonymous-schema-316>
                required:
                  - type
                  - user
                x-parser-schema-id: <anonymous-schema-314>
              minItems: 1
              default:
                - type: account
                  user: ''
              description: >-
                Playground form template only. Paste an account public key into
                user before sending; the blank value is not a valid account and
                no account is preselected.
              x-parser-schema-id: <anonymous-schema-313>
          required:
            - method
            - subscription
          x-parser-schema-id: <anonymous-schema-311>
        title: Subscribe
        description: >-
          Schema defaults on this request are playground example prefills, not
          omitted-field defaults accepted by the network endpoint.
        example: |-
          {
            "method": "subscribe",
            "subscription": [
              {
                "type": "account",
                "user": "FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7"
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: account-risk
  - &ref_2
    id: account-riskEvents
    title: Receive events
    type: send
    messages:
      - &ref_4
        id: liquidation
        contentType: application/json
        payload:
          - name: Liquidation
            description: Network-published liquidation
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - account
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: type
                    type: string
                    enumValues:
                      - liquidation
                    required: true
                  - name: symbol
                    type: string
                    required: false
                  - name: price
                    type: number
                    required: false
                  - name: size
                    type: number
                    required: false
                  - name: isBuy
                    type: boolean
                    required: false
                  - name: marginPrior
                    type: number
                    required: false
                  - name: marginAfter
                    type: number
                    required: false
                  - name: reason
                    type: string
                    required: false
                  - name: timestamp
                    type: number
                    description: Unix timestamp in nanoseconds.
                    required: false
              - name: topic
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - account
              x-parser-schema-id: <anonymous-schema-519>
            data:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - liquidation
                  x-parser-schema-id: <anonymous-schema-521>
                symbol:
                  type: string
                  x-parser-schema-id: <anonymous-schema-522>
                price:
                  type: number
                  x-parser-schema-id: <anonymous-schema-523>
                size:
                  type: number
                  x-parser-schema-id: <anonymous-schema-524>
                isBuy:
                  type: boolean
                  x-parser-schema-id: <anonymous-schema-525>
                marginPrior:
                  type: number
                  x-parser-schema-id: <anonymous-schema-526>
                marginAfter:
                  type: number
                  x-parser-schema-id: <anonymous-schema-527>
                reason:
                  type: string
                  x-parser-schema-id: <anonymous-schema-528>
                timestamp:
                  type: number
                  description: Unix timestamp in nanoseconds.
                  x-parser-schema-id: <anonymous-schema-529>
              required:
                - type
              x-parser-schema-id: <anonymous-schema-520>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-530>
          required:
            - type
            - data
            - topic
          x-parser-schema-id: <anonymous-schema-518>
        title: Liquidation
        description: Network-published liquidation
        example: |-
          {
            "type": "account",
            "data": {
              "type": "liquidation",
              "symbol": "BTC-USD",
              "price": 95000,
              "size": 0.5,
              "isBuy": false,
              "marginPrior": 5000,
              "marginAfter": 0,
              "reason": "margin shortfall",
              "timestamp": 1763316177219383300
            },
            "topic": "account.FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: liquidation
      - &ref_5
        id: liquidationMargin
        contentType: application/json
        payload:
          - name: Liquidation margin
            description: Network-published liquidationMargin
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - account
                required: true
              - name: topic
                type: string
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: type
                    type: string
                    enumValues:
                      - liquidationMargin
                    required: true
                  - name: liquidator
                    type: string
                    required: false
                  - name: loss
                    type: number
                    required: false
                  - name: shortfall
                    type: number
                    required: false
                  - name: transfers
                    type: array
                    required: false
                    properties:
                      - name: from
                        type: string
                        required: false
                      - name: to
                        type: string
                        required: false
                      - name: symbol
                        type: string
                        required: false
                      - name: amountAtoms
                        type: number
                        required: false
                  - name: iso
                    type: boolean
                    required: false
                  - name: timestamp
                    type: number
                    description: Unix timestamp in nanoseconds.
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - account
              x-parser-schema-id: <anonymous-schema-532>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-533>
            data:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - liquidationMargin
                  x-parser-schema-id: <anonymous-schema-535>
                liquidator:
                  type: string
                  x-parser-schema-id: <anonymous-schema-536>
                loss:
                  type: number
                  x-parser-schema-id: <anonymous-schema-537>
                shortfall:
                  type: number
                  x-parser-schema-id: <anonymous-schema-538>
                transfers:
                  type: array
                  items:
                    type: object
                    properties:
                      from:
                        type: string
                        x-parser-schema-id: <anonymous-schema-541>
                      to:
                        type: string
                        x-parser-schema-id: <anonymous-schema-542>
                      symbol:
                        type: string
                        x-parser-schema-id: <anonymous-schema-543>
                      amountAtoms:
                        type: number
                        x-parser-schema-id: <anonymous-schema-544>
                    x-parser-schema-id: <anonymous-schema-540>
                  x-parser-schema-id: <anonymous-schema-539>
                iso:
                  type: boolean
                  x-parser-schema-id: <anonymous-schema-545>
                timestamp:
                  type: number
                  description: Unix timestamp in nanoseconds.
                  x-parser-schema-id: <anonymous-schema-546>
              required:
                - type
              x-parser-schema-id: <anonymous-schema-534>
          required:
            - type
            - data
            - topic
          x-parser-schema-id: <anonymous-schema-531>
        title: Liquidation margin
        description: Network-published liquidationMargin
        example: |-
          {
            "type": "account",
            "topic": "account.FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7",
            "data": {
              "type": "liquidationMargin",
              "liquidator": "5Am6JkEHAjYG1itNWRMGpQrxvY8AaqkXCo1TZvenqVux",
              "loss": 12.5,
              "shortfall": 2.25,
              "transfers": [
                {
                  "from": "FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7",
                  "to": "5Am6JkEHAjYG1itNWRMGpQrxvY8AaqkXCo1TZvenqVux",
                  "symbol": "USDC",
                  "amountAtoms": 10250000
                }
              ],
              "iso": false,
              "timestamp": 1700000000000000000
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: liquidationMargin
      - &ref_6
        id: adl
        contentType: application/json
        payload:
          - name: ADL
            description: Network-published adl
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - account
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: type
                    type: string
                    enumValues:
                      - adl
                    required: true
                  - name: symbol
                    type: string
                    required: false
                  - name: price
                    type: number
                    required: false
                  - name: size
                    type: number
                    required: false
                  - name: isBuy
                    type: boolean
                    required: false
                  - name: reason
                    type: string
                    required: false
                  - name: timestamp
                    type: number
                    description: Unix timestamp in nanoseconds.
                    required: false
              - name: topic
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - account
              x-parser-schema-id: <anonymous-schema-548>
            data:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - adl
                  x-parser-schema-id: <anonymous-schema-550>
                symbol:
                  type: string
                  x-parser-schema-id: <anonymous-schema-551>
                price:
                  type: number
                  x-parser-schema-id: <anonymous-schema-552>
                size:
                  type: number
                  x-parser-schema-id: <anonymous-schema-553>
                isBuy:
                  type: boolean
                  x-parser-schema-id: <anonymous-schema-554>
                reason:
                  type: string
                  x-parser-schema-id: <anonymous-schema-555>
                timestamp:
                  type: number
                  description: Unix timestamp in nanoseconds.
                  x-parser-schema-id: <anonymous-schema-556>
              required:
                - type
              x-parser-schema-id: <anonymous-schema-549>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-557>
          required:
            - type
            - data
            - topic
          x-parser-schema-id: <anonymous-schema-547>
        title: ADL
        description: Network-published adl
        example: |-
          {
            "type": "account",
            "data": {
              "type": "adl",
              "symbol": "BTC-USD",
              "price": 95000,
              "size": 0.5,
              "isBuy": false,
              "reason": "underfill residual",
              "timestamp": 1763316177219383300
            },
            "topic": "account.FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: adl
      - &ref_7
        id: subscribed
        contentType: application/json
        payload:
          - name: Subscribed
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - subscriptionResponse
                required: true
              - name: topics
                type: array
                required: false
                properties:
                  - name: item
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - subscriptionResponse
              x-parser-schema-id: <anonymous-schema-418>
            topics:
              type: array
              items:
                type: string
                x-parser-schema-id: <anonymous-schema-420>
              x-parser-schema-id: <anonymous-schema-419>
          required:
            - type
          x-parser-schema-id: <anonymous-schema-417>
        title: Subscribed
        example: |-
          {
            "type": "subscriptionResponse",
            "topics": [
              "account.FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribed
      - &ref_8
        id: unsubscribed
        contentType: application/json
        payload:
          - name: Unsubscribed
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - unsubscribeResponse
                required: true
              - name: topic
                type: string
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - unsubscribeResponse
              x-parser-schema-id: <anonymous-schema-422>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-423>
          required:
            - type
          x-parser-schema-id: <anonymous-schema-421>
        title: Unsubscribed
        example: |-
          {
            "type": "unsubscribeResponse",
            "topic": "account.FuueqefENiGEW6uMqZQgmwjzgpnb85EgUcZa5Em4PQh7"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribed
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
receiveMessages:
  - *ref_4
  - *ref_5
  - *ref_6
  - *ref_7
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: account-risk
securitySchemes: []

````

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