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

# Liquidations

> DEX liquidation events and account-level liquidation context.

The `lighter_robinhood.dex.liquidations` table contains dex liquidation events and account-level liquidation context.

## Table Columns

**Unique key:** `trade_id`

| Column Name                            | Data Type          | Description                                                                                                         |
| -------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------- |
| `market_type`                          | `VARCHAR`          | 'perpetuals' or 'spot'.                                                                                             |
| `coin`                                 | `VARCHAR`          | Market symbol.                                                                                                      |
| `token_a_symbol`                       | `VARCHAR`          | Base token symbol.                                                                                                  |
| `token_b_symbol`                       | `VARCHAR`          | Quote token symbol.                                                                                                 |
| `amount`                               | `NUMBER(22,10)`    | Liquidation size in base asset units.                                                                               |
| `price`                                | `NUMBER(22,10)`    | Execution price.                                                                                                    |
| `usd_amount`                           | `NUMBER(22,10)`    | USD value of the liquidation.                                                                                       |
| `liquidated_account_id`                | `VARCHAR`          | Account ID of the liquidated party.                                                                                 |
| `counterparty_account_id`              | `VARCHAR`          | Account ID of the counterparty (maker).                                                                             |
| `liquidated_l1_address`                | `VARCHAR`          | EVM wallet address of the liquidated party. NULL if no mapping exists.                                              |
| `counterparty_l1_address`              | `VARCHAR`          | EVM wallet address of the counterparty. NULL if no mapping exists.                                                  |
| `buyer`                                | `VARCHAR`          | Account ID of the buyer (bid side).                                                                                 |
| `seller`                               | `VARCHAR`          | Account ID of the seller (ask side).                                                                                |
| `buyer_l1_address`                     | `VARCHAR`          | EVM wallet address of the buyer. NULL if no mapping exists.                                                         |
| `seller_l1_address`                    | `VARCHAR`          | EVM wallet address of the seller. NULL if no mapping exists.                                                        |
| `is_maker_ask`                         | `BOOLEAN`          | True if the maker is on the ask (sell) side.                                                                        |
| `timestamp`                            | `TIMESTAMP_NTZ(9)` | UTC timestamp of the event.                                                                                         |
| `transaction_hash`                     | `VARCHAR`          | On-chain transaction hash.                                                                                          |
| `trade_id`                             | `VARCHAR`          | Unique trade identifier.                                                                                            |
| `unique_id`                            | `VARCHAR`          | Unique identifier for the liquidation.                                                                              |
| `block_height`                         | `NUMBER(38,0)`     | Block height of the liquidation.                                                                                    |
| `buyer_order_id`                       | `VARCHAR`          | The order ID for the buyer's order.                                                                                 |
| `seller_order_id`                      | `VARCHAR`          | The order ID for the seller's order.                                                                                |
| `buyer_client_id`                      | `VARCHAR`          | Client-assigned order ID for the buyer.                                                                             |
| `seller_client_id`                     | `VARCHAR`          | Client-assigned order ID for the seller.                                                                            |
| `fee_token`                            | `VARCHAR`          | The token in which fees were paid.                                                                                  |
| `buyer_fee`                            | `NUMBER(22,10)`    | Fee paid by the buyer in USD.                                                                                       |
| `seller_fee`                           | `NUMBER(22,10)`    | Fee paid by the seller in USD.                                                                                      |
| `liquidation_fee_rate`                 | `NUMBER(22,10)`    | Liquidation fee rate as a decimal fraction.                                                                         |
| `liquidation_fee_amount`               | `NUMBER(22,10)`    | Liquidation fee in USD.                                                                                             |
| `maker_fee_rate`                       | `NUMBER(22,10)`    | Maker fee rate as a decimal fraction.                                                                               |
| `maker_fee_amount`                     | `NUMBER(22,10)`    | Maker fee in USD.                                                                                                   |
| `buyer_start_position`                 | `NUMBER(22,10)`    | The buyer's position before this trade.                                                                             |
| `seller_start_position`                | `NUMBER(22,10)`    | The seller's position before this trade.                                                                            |
| `liquidated_position_size_before`      | `NUMBER(22,10)`    | Liquidated account's position before event.                                                                         |
| `liquidated_entry_quote_before`        | `NUMBER(22,10)`    | Liquidated account's entry quote before this liquidation event.                                                     |
| `liquidated_initial_margin_fraction`   | `NUMBER(38,0)`     | Liquidated account's initial margin fraction at the time of this liquidation event.                                 |
| `counterparty_position_size_before`    | `NUMBER(22,10)`    | Counterparty's position size before this liquidation event.                                                         |
| `counterparty_entry_quote_before`      | `NUMBER(22,10)`    | Counterparty's entry quote before this liquidation event.                                                           |
| `counterparty_initial_margin_fraction` | `NUMBER(38,0)`     | Counterparty's initial margin fraction at the time of this liquidation event.                                       |
| `liquidated_position_sign_changed`     | `BOOLEAN`          | True if the liquidated account's position changed sign (long to short or vice versa) during this liquidation event. |
| `counterparty_position_sign_changed`   | `BOOLEAN`          | True if the counterparty's position changed sign (long to short or vice versa) during this liquidation event.       |
| `market_id`                            | `NUMBER(38,0)`     | Lighter market identifier.                                                                                          |
| `collateral_asset_id`                  | `NUMBER(38,0)`     | Collateral asset ID for perpetuals.                                                                                 |
| `collateral_symbol`                    | `VARCHAR`          | Collateral asset symbol for perpetuals (for example, USDG). NULL for spots.                                         |
| `base_l1_address`                      | `VARCHAR`          | L1 contract address of the base asset, when applicable.                                                             |
| `market_max_leverage`                  | `NUMBER(12,6)`     | Maximum leverage for this market.                                                                                   |
| `liquidated_max_leverage`              | `NUMBER(12,6)`     | Liquidated account's max leverage.                                                                                  |
| `maintenance_margin_fraction`          | `NUMBER(38,0)`     | Market maintenance margin fraction.                                                                                 |
| `closeout_margin_fraction`             | `NUMBER(38,0)`     | Market closeout margin fraction.                                                                                    |
| `transaction_time`                     | `VARCHAR`          | Unix transaction timestamp in microseconds, represented as text.                                                    |
| `transaction_time_ts`                  | `TIMESTAMP_NTZ(9)` | UTC transaction timestamp.                                                                                          |
| `_created_at`                          | `TIMESTAMP_NTZ(9)` | Timestamp when the row was first recorded.                                                                          |
| `_updated_at`                          | `TIMESTAMP_NTZ(9)` | Timestamp when the row was last updated.                                                                            |

### Sample Query

```sql theme={null}
SELECT
    timestamp,
    coin,
    usd_amount,
    liquidated_account_id,
    counterparty_account_id
FROM lighter_robinhood.dex.liquidations
WHERE timestamp >= CURRENT_DATE - 7
ORDER BY timestamp DESC
LIMIT 100;
```
