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

# dex.sandwiched

> The `dex.sandwiched` table captures detailed data on the victim trades of sandwich attacks in decentralized exchanges (DEXs), recording transactions that have been sandwiched across various EVM networks.

export const TableSample = ({tableName, tableSchema}) => <>
    <div className="hidden dark:block">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}&darkMode=true`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
    <div className="dark:hidden">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
  </>;

## Table Description

The `dex.sandwiched` table captures detailed data on the victim trades of sandwich attacks executed via decentralized exchanges (DEXs). This table records the transactions that have been sandwiched between front-running and back-running trades. It provides a comprehensive view of sandwich attack victims across various EVM networks.

## Functional Overview

The `dex.sandwiched` table provides an in-depth view of the victim trades in sandwich attacks on decentralized exchanges. A sandwich attack occurs when a trader (usually a bot) spots a pending transaction in the mempool, quickly executes a trade before it (front-running), and then immediately after it (back-running) to profit from the price movement caused by the victim's trade.

This table includes entries for:

1. The victim trade that has been sandwiched

Note that the front-running and back-running trades that sandwich these victim trades are captured in a separate table, `dex.sandwiches`.

This detailed approach allows for granular analysis of sandwich attack patterns, enabling users to:

* **Identify Sandwich Attack Victims**: Easily spot instances of trades that have been sandwiched across different DEXs and networks.
* **Analyze Attack Impacts**: Understand the frequency, size, and potential losses of sandwiched trades.
* **Monitor Market Vulnerability**: Gain insights into which trades are most susceptible to sandwich attacks across different DEXs and EVM networks.

By providing comprehensive details of the victim trades in sandwich attacks, the `dex.sandwiched` table supports advanced analytics and research into DEX trading behavior, market manipulation, and potential areas for improved trade execution or protocol design to protect users from sandwich attacks.

## Table Schema

| Column                     | Type        | Description                                                    |
| -------------------------- | ----------- | -------------------------------------------------------------- |
| `blockchain`               | `VARCHAR`   | Blockchain on which this trade occurred                        |
| `project`                  | `VARCHAR`   | Name of the DEX on which the trade occurred                    |
| `version`                  | `VARCHAR`   | Version of the DEX protocol/contract                           |
| `block_time`               | `TIMESTAMP` | UTC event block time                                           |
| `block_month`              | `DATE`      | UTC event block month (partition key)                          |
| `block_number`             | `BIGINT`    | Block number in which the trade occurred                       |
| `token_sold_address`       | `VARBINARY` | Contract address of the token sold                             |
| `token_bought_address`     | `VARBINARY` | Contract address of the token bought                           |
| `token_sold_symbol`        | `VARCHAR`   | Symbol of the token sold                                       |
| `token_bought_symbol`      | `VARCHAR`   | Symbol of the token bought                                     |
| `maker`                    | `VARBINARY` | Address that sold tokens (can be contract or EOA)              |
| `taker`                    | `VARBINARY` | Address that purchased tokens (can be contract or EOA)         |
| `tx_hash`                  | `VARBINARY` | Transaction hash                                               |
| `tx_from`                  | `VARBINARY` | EOA address that sent the transaction                          |
| `tx_to`                    | `VARBINARY` | Address called in the first call of this transaction           |
| `project_contract_address` | `VARBINARY` | Smart contract address which emitted the trade event           |
| `token_pair`               | `VARCHAR`   | Symbol pair for the tokens involved, always alphabetical order |
| `tx_index`                 | `BIGINT`    | Index of the transaction in the block                          |
| `token_sold_amount_raw`    | `UINT256`   | Raw amount of the token sold                                   |
| `token_bought_amount_raw`  | `UINT256`   | Raw amount of the token bought                                 |
| `token_sold_amount`        | `DOUBLE`    | Amount of the token sold in display units                      |
| `token_bought_amount`      | `DOUBLE`    | Amount of the token bought in display units                    |
| `amount_usd`               | `DOUBLE`    | USD value of the trade at time of execution                    |
| `evt_index`                | `BIGINT`    | Index of the event in the transaction                          |

## Table Sample

<TableSample tableSchema="dex" tableName="sandwiched" />

## Related Tables

* `dex.sandwiches`: This complementary table captures the front-running and back-running trades that sandwich the victim trades recorded in `dex.sandwiched`.
* `dex.trades`: This table captures all trades and is the basis for the `dex.sandwiched` table.
