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

# Trades

> Track RWA spot and perpetual trades across different blockchains and platforms.

## Overview

The trades tables capture trading activity for RWA tokens across dedicated RWA platforms, decentralized exchanges, and perpetual futures venues. `rwa.core` splits spot and perpetual trades into separate tables and exposes both sides of each trade (sold and bought legs) with full product and issuer enrichment.

## Methodology

* *RWA Platforms*: Tokenization platforms where users buy/sell tokenized assets directly. Currently supported: Ondo Global Markets, Dinari, StableStock, Swarm.

* *DEXs*: Decentralized exchanges where tokenized RWA assets trade against other tokens via liquidity pools. Covers all EVM and Solana DEXs supported by Allium.

* *Perpetual Futures*: Exchange-listed perpetual contracts referencing real-world assets. Currently supported: Hyperliquid HIP-3, Lighter, Lighter Robinhood.

<Info>
  The trades tables are currently in Beta. Coverage and metrics will be expanded over time.
</Info>

## Tables

| Table                            | Description                                                                                                                                                                 |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rwa.core.spot_trades`           | All RWA spot trades (RWA platforms + DEXs). Directional token\_sold / token\_bought schema. Includes product\_id and issuer\_id enrichment per leg.                         |
| `rwa.core.perpetual_trades`      | Perpetual futures trades on Hyperliquid HIP-3, Lighter, and Lighter Robinhood. Same directional schema; no product\_id/issuer\_id (perp positions are not on-chain tokens). |
| `crosschain.rwa.trades`          | Legacy: all RWA spot trades (RWA platforms + DEXs). Single-token view — counterparty leg is not exposed. Use `rwa.core.spot_trades` for new work.                           |
| `crosschain.rwa.equities_trades` | Legacy: filtered view of `crosschain.rwa.trades` for tokenized equities only.                                                                                               |

## Table Columns

<Tabs>
  <Tab title="rwa.core.spot_trades">
    Spot trades across RWA platforms and DEXs, using a directional `token_sold` / `token_bought` schema that exposes both legs of each swap.

    Unique key: `unique_id`

    | Column                        | Description                                                                                                      |
    | ----------------------------- | ---------------------------------------------------------------------------------------------------------------- |
    | `chain`                       | Blockchain where the trade occurred (e.g., `ethereum`, `solana`, `base`)                                         |
    | `block_date`                  | UTC date of the block                                                                                            |
    | `block_timestamp`             | Timestamp of the block                                                                                           |
    | `block_number`                | Block number                                                                                                     |
    | `platform_type`               | `rwa_platform` or `dex`                                                                                          |
    | `project`                     | Project name (e.g., `ondo`, `uniswap`)                                                                           |
    | `protocol`                    | Protocol version (e.g., `ondo_global_markets`, `uniswap_v3`)                                                     |
    | `rwa_side`                    | Which leg is the RWA token: `buy` (RWA bought), `sell` (RWA sold), or `rwa_to_rwa`                               |
    | `asset_class`                 | Top-level V2 classification (`rates`, `equities`, `credit`, `fx`, `commodities`, `private_funds`, `real_estate`) |
    | `token_sold_address`          | Contract address of the token sold                                                                               |
    | `token_sold_name`             | Name of the token sold                                                                                           |
    | `token_sold_symbol`           | Symbol of the token sold                                                                                         |
    | `token_sold_decimals`         | Decimals of the token sold                                                                                       |
    | `token_sold_amount`           | Normalized amount sold                                                                                           |
    | `token_sold_amount_str`       | Normalized amount sold (string, full precision)                                                                  |
    | `token_sold_amount_raw`       | Raw (smallest-unit) amount sold                                                                                  |
    | `token_sold_amount_raw_str`   | Raw amount sold (string, full precision)                                                                         |
    | `token_sold_product_id`       | Allium product ID of the sold token if it is an RWA; null otherwise                                              |
    | `token_sold_issuer_id`        | Allium issuer ID of the sold token if it is an RWA; null otherwise                                               |
    | `token_bought_address`        | Contract address of the token bought                                                                             |
    | `token_bought_name`           | Name of the token bought                                                                                         |
    | `token_bought_symbol`         | Symbol of the token bought                                                                                       |
    | `token_bought_decimals`       | Decimals of the token bought                                                                                     |
    | `token_bought_amount`         | Normalized amount bought                                                                                         |
    | `token_bought_amount_str`     | Normalized amount bought (string, full precision)                                                                |
    | `token_bought_amount_raw`     | Raw amount bought                                                                                                |
    | `token_bought_amount_raw_str` | Raw amount bought (string, full precision)                                                                       |
    | `token_bought_product_id`     | Allium product ID of the bought token if it is an RWA; null otherwise                                            |
    | `token_bought_issuer_id`      | Allium issuer ID of the bought token if it is an RWA; null otherwise                                             |
    | `usd_amount`                  | USD value of the trade                                                                                           |
    | `sender_address`              | Address that sent the transaction                                                                                |
    | `to_address`                  | Recipient address                                                                                                |
    | `liquidity_pool_address`      | Liquidity pool contract address (DEX trades)                                                                     |
    | `transaction_hash`            | Transaction hash                                                                                                 |
    | `transaction_index`           | Index of the transaction in the block                                                                            |
    | `transaction_from_address`    | EOA that signed the transaction                                                                                  |
    | `transaction_to_address`      | Contract the transaction was sent to                                                                             |
    | `extra_fields`                | Additional trade-specific metadata (VARIANT)                                                                     |
    | `unique_id`                   | Unique identifier for the trade row                                                                              |
    | `_trades_created_at`          | When the underlying trade record was first ingested                                                              |
    | `_trades_updated_at`          | When the underlying trade record was last updated                                                                |
    | `_created_at`                 | When this row was created                                                                                        |
    | `_updated_at`                 | When this row was last updated                                                                                   |
  </Tab>

  <Tab title="rwa.core.perpetual_trades">
    Perpetual futures trades for RWA-referenced markets on Hyperliquid HIP-3, Lighter, and Lighter Robinhood. Uses the same directional schema as spot trades.

    Note: perpetual positions are exchange-listed contracts, not on-chain tokens, so `token_sold_product_id` / `token_bought_product_id` / `token_sold_issuer_id` are not present — use `rwa.metrics.perpetual_markets_daily` to get market-level metadata.

    Unique key: `unique_id`

    | Column                        | Description                                                      |
    | ----------------------------- | ---------------------------------------------------------------- |
    | `chain`                       | Chain where the trade occurred (e.g., `hyperliquid`, `lighter`)  |
    | `block_date`                  | UTC date of the block                                            |
    | `block_timestamp`             | Timestamp of the block                                           |
    | `block_number`                | Block number                                                     |
    | `platform_type`               | Always `dex` for perpetual venues                                |
    | `project`                     | Project name (e.g., `hyperliquid`, `lighter`)                    |
    | `protocol`                    | Protocol variant (e.g., `hyperliquid_hip3`, `lighter_robinhood`) |
    | `rwa_side`                    | Which leg is the RWA exposure: `buy`, `sell`, or `rwa_to_rwa`    |
    | `asset_class`                 | Top-level V2 classification of the referenced asset              |
    | `token_sold_address`          | Market identifier of the token/position sold                     |
    | `token_sold_name`             | Name of the token sold                                           |
    | `token_sold_symbol`           | Symbol of the token sold (e.g., `AAPL`, `GOLD`)                  |
    | `token_sold_decimals`         | Decimals                                                         |
    | `token_sold_amount`           | Normalized amount sold                                           |
    | `token_sold_amount_str`       | Normalized amount sold (string)                                  |
    | `token_sold_amount_raw`       | Raw amount sold                                                  |
    | `token_sold_amount_raw_str`   | Raw amount sold (string)                                         |
    | `token_bought_address`        | Market identifier of the token/position bought                   |
    | `token_bought_name`           | Name of the token bought                                         |
    | `token_bought_symbol`         | Symbol of the token bought                                       |
    | `token_bought_decimals`       | Decimals                                                         |
    | `token_bought_amount`         | Normalized amount bought                                         |
    | `token_bought_amount_str`     | Normalized amount bought (string)                                |
    | `token_bought_amount_raw`     | Raw amount bought                                                |
    | `token_bought_amount_raw_str` | Raw amount bought (string)                                       |
    | `usd_amount`                  | USD value of the trade                                           |
    | `sender_address`              | Address that sent the transaction                                |
    | `to_address`                  | Recipient address                                                |
    | `liquidity_pool_address`      | Exchange contract address                                        |
    | `transaction_hash`            | Transaction hash                                                 |
    | `transaction_index`           | Index of the transaction in the block                            |
    | `transaction_from_address`    | EOA that signed the transaction                                  |
    | `transaction_to_address`      | Contract the transaction was sent to                             |
    | `extra_fields`                | Additional trade-specific metadata (VARIANT)                     |
    | `unique_id`                   | Unique identifier for the trade row                              |
    | `_trades_created_at`          | When the underlying trade record was first ingested              |
    | `_trades_updated_at`          | When the underlying trade record was last updated                |
    | `_created_at`                 | When this row was created                                        |
    | `_updated_at`                 | When this row was last updated                                   |
  </Tab>

  <Tab title="crosschain.rwa.trades (legacy)">
    Legacy all-in-one trades table. Only the RWA leg of each trade is exposed — the counterparty token is not. Use `rwa.core.spot_trades` for new work.

    Unique key: `unique_id`

    | Column                     | Description                                                           |
    | -------------------------- | --------------------------------------------------------------------- |
    | `chain`                    | Blockchain where the RWA token is traded                              |
    | `platform_type`            | `rwa_platform` or `dex`                                               |
    | `platform`                 | Platform name (e.g., `ondo_global_markets`, `uniswap_v3`)             |
    | `asset_class`              | Top-level V2 classification                                           |
    | `asset_type`               | Granular V2 sub-classification                                        |
    | `issuer`                   | Issuer of the RWA token                                               |
    | `product_id`               | Allium product ID                                                     |
    | `token_address`            | Contract address of the RWA token                                     |
    | `ticker`                   | RWA token ticker                                                      |
    | `underlying_ticker`        | Underlying asset ticker (e.g., the stock ticker the token represents) |
    | `name`                     | RWA token name                                                        |
    | `rwa_side`                 | `buy`, `sell`, or `rwa_to_rwa`                                        |
    | `amount`                   | Amount of the RWA token traded                                        |
    | `usd_amount`               | USD value of the trade                                                |
    | `block_timestamp`          | Block timestamp                                                       |
    | `block_number`             | Block number                                                          |
    | `transaction_hash`         | Transaction hash                                                      |
    | `transaction_from_address` | EOA that signed the transaction                                       |
    | `extra_fields`             | Additional metadata (VARIANT)                                         |
    | `unique_id`                | Unique identifier for the trade row                                   |
    | `_created_at`              | When this row was created                                             |
    | `_updated_at`              | When this row was last updated                                        |
  </Tab>
</Tabs>

## `rwa.core` vs `crosschain.rwa` — Key Differences

|                             | `rwa.core.spot_trades`                  | `crosschain.rwa.trades`        |
| --------------------------- | --------------------------------------- | ------------------------------ |
| Both trade legs visible     | Yes — `token_sold` + `token_bought`     | No — RWA leg only              |
| Product / issuer enrichment | Per-leg (`token_sold_product_id`, etc.) | Single `product_id` / `issuer` |
| Perp trades                 | Separate `rwa.core.perpetual_trades`    | Merged into one table          |
| Status                      | Current                                 | Legacy                         |

## Sample Queries

```sql theme={null}
-- Daily RWA spot trade volume by asset class
SELECT
    block_date,
    asset_class,
    SUM(usd_amount) AS volume_usd
FROM rwa.core.spot_trades
GROUP BY 1, 2
ORDER BY 1 DESC, 3 DESC
```

```sql theme={null}
-- Perpetual trades for equities on Hyperliquid, last 7 days
SELECT
    block_date,
    token_sold_symbol,
    token_bought_symbol,
    SUM(usd_amount) AS volume_usd,
    COUNT(*) AS trade_count
FROM rwa.core.perpetual_trades
WHERE asset_class = 'equities'
  AND block_date >= CURRENT_DATE - 7
GROUP BY 1, 2, 3
ORDER BY 1 DESC, 4 DESC
```

```sql theme={null}
-- Find all trades involving a specific RWA product (either side)
SELECT *
FROM rwa.core.spot_trades
WHERE token_sold_product_id = 'usdy'
   OR token_bought_product_id = 'usdy'
ORDER BY block_timestamp DESC
LIMIT 100
```
