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

# Uniswap X Trades

> UniswapX: Dutch Order Reactor orders and settlement. This

### Table Details

| Property | Value |
| - | - |
| Table Name | `ethereum.dex.uniswap_x_trades` |
| Table Status | Production-Ready |
| Unique Key | `block_timestamp`, `unique_id` |
| Clustering Key(s) | `block_timestamp::date` |

`ethereum.dex.uniswap_x_trades` table includes all trades **including failed** `execute` calls from Uniswap X's [`ExclusiveDutchOrderReactor`](https://etherscan.io/address/0x6000da47483062a0d734ba3dc7576ce6a0b645c4) .

> [!NOTE]
>
> ⚠️ **This model includes failed orders that failed to execute.**
>
> To filter them out, set status = 1 (see example below) .These trades amount to \~1.6% of total volume, and \~3% of all trades.

> [card]
>
> UniswapX is a new permissionless, open source (GPL), auction-based routing protocol for trading across AMMs and other liquidity sources.
>
> [Open](https://docs.uniswap.org/contracts/uniswapx/overview)

### Table Columns

Note that the decoded orders can be found in the `extra_fields` column.

| Column Name | Data Type | Description |
| - | - | - |
| exclusive\_filler | VARCHAR(134217728) | Address of the exclusive filler. |
| exclusivity\_override\_bps | NUMBER(38,0) | The amount in bps that a non-exclusive filler needs to improve the outputs by to be able to fill the order. |
| reactor | VARCHAR(134217728) | Address or the reactor. Order Reactors settle UniswapX orders. They are responsible for validating orders of a specific type, resolving them into inputs and outputs, and executing them against the filler's strategy, and verifying that the order was successfully fulfilled. |
| swapper | VARCHAR(134217728) | Address of the swapper. |
| input | VARIANT | Encoded calldata sent with the transaction. For contract calls, contains the function selector (first 4 bytes) and ABI-encoded arguments. Empty for simple ETH transfers. |
| outputs | VARIANT | Array of outputs. Note that there can be > 1 outputs for a single trade. Most of the case the bulk of the output values goes to the first output. |
| orders | VARIANT | JSON object containing the full decoded order parameters for this UniswapX trade, including reactor address, swapper, input token specification, output token specifications, and exclusivity settings. |
| project | VARCHAR(134217728) | Project name. |
| protocol | VARCHAR(134217728) | Protocol name. |
| event\_name | VARCHAR(134217728) | Source SettlementPool event name: Deposited or Withdrawn. |
| contract\_address | VARCHAR(42) | Address of the smart contract that emitted this event or was called in this transaction. |
| liquidity\_pool\_address | VARCHAR(42) | Contract address of the liquidity pool where this trade was executed. Null when the routing path is not emitted by the event (common for aggregator trades). |
| sender\_address | VARCHAR(42) | Address that initiated the bridge transfer on the source chain. |
| to\_address | VARCHAR(42) | Address that received in this event. For token transfers, the account whose balance increased. For transactions, the destination address (may be a smart contract). |
| token\_sold\_address | VARCHAR(42) | Input token address. Input tokens will map to token sold. Native ETH will be represented as zero address `0x0000000000000000000000000000000000000000`. |
| token\_sold\_name | VARCHAR(134217728) | Input token name. |
| token\_sold\_symbol | VARCHAR(134217728) | Input token symbol. |
| token\_sold\_amount\_raw\_str | VARCHAR(134217728) | Raw amount of the token sold as a string for full precision. |
| token\_sold\_amount\_raw | FLOAT | Input token amount, unnormalized, in string. |
| token\_sold\_amount\_str | VARCHAR(134217728) | Decimal-adjusted amount of the token sold as a string for full precision. |
| token\_sold\_amount | FLOAT | Input token amount, normalized. |
| usd\_sold\_amount | FLOAT | USD value of the input token. |
| token\_bought\_address | VARCHAR(42) | First output token address. Output tokens will map to tokens bought. Native ETH will be represented as zero address `0x0000000000000000000000000000000000000000`. |
| token\_bought\_name | VARCHAR(134217728) | First output token name. |
| token\_bought\_symbol | VARCHAR(134217728) | First output token address. |
| token\_bought\_amount\_raw\_str | VARCHAR(134217728) | Raw amount of the token bought as a string for full precision. |
| token\_bought\_amount\_raw | FLOAT | Amount of token bought, unnormalized and in string. |
| token\_bought\_amount\_str | VARCHAR(134217728) | Decimal-adjusted amount of the token bought as a string for full precision. |
| token\_bought\_amount | FLOAT | Amount of token bought, normalized. |
| usd\_bought\_amount | FLOAT | USD amount of token bought, normalized. |
| usd\_amount | FLOAT | USD value of the swap. We preferentially select the input (token sold) usd value. If this is not available, we will select the output. |
| transaction\_from\_address | VARCHAR(42) | The address of the sending party of this transaction. |
| transaction\_to\_address | VARCHAR(42) | The address of the receiving party of this transaction (could be a contract address). |
| transaction\_hash | VARCHAR(66) | Transaction hash of this trade. |
| transaction\_index | NUMBER(38,0) | Transaction index of this trade in the block. |
| transaction\_fees | FLOAT | Fees paid at the transaction level. |
| transaction\_fees\_usd | FLOAT | Fees paid in USD. |
| fee\_details | VARIANT | Additional fee details of the transaction, including max priority fee, gas price and gas used for the transaction. |
| selector | VARCHAR(134217728) | First 4 bytes of the transaction calldata, identifying the function being called. Null for plain native-currency transfers. Also known as the function selector. |
| log\_index | NUMBER(38,0) | Log index of this trade. |
| block\_timestamp | TIMESTAMP\_NTZ(9) | Block timestamp of this trade. |
| block\_number | NUMBER(38,0) | Block number of this trade. |
| block\_hash | VARCHAR(66) | Block hash of this trade. |
| unique\_id | VARCHAR(134217728) | Unique ID of each trade. |
| \_created\_at | TIMESTAMP\_NTZ(9) | Timestamp of the entry creation. |
| \_updated\_at | TIMESTAMP\_NTZ(9) | Timestamp of the entry update. |
| \_changed\_since\_full\_refresh | BOOLEAN | Indicates if the record has changed since the last full data refresh. |
| integrator | VARCHAR(134217728) | Name or identifier of the dApp or protocol that submitted this order through an aggregator (e.g. `"1inch"`, `"paraswap"`, `"cowswap"`). Populated from order metadata where available. |
| integrator\_tag | VARCHAR(134217728) | Normalised tag for the integrator, used for grouping and filtering (lowercase, no spaces). Derived from the `integrator` field. |

### Sample Query

```sql theme={null}
-- Daily Swap Volume 
select 
    date(block_timestamp) as date, 
    sum(usd_amount) as usd_volume,
    count(distinct transaction_hash) as txn_count
from ethereum.dex.uniswap_x_trades
where status = 1 
group by all 
```

### Methodology

* Identify the following trace call from UniswapX `ExclusiveDutchOrderReactor` contract

  * `executeBatchWithCallback executeWithCallback executeBatch execute`

* From the trace calls, we fetch the serialised **order** and ABI decode.

* From event logs, we join the corresponding `Fill` event emitted by the `ExclusiveDutchOrderReactor` contract

> [tab] Serialized Order
>
> Using this transaction as an example: [https://etherscan.io/tx/0xc3cb3b518f455144d153e6d086b8688d6678b7318ab928b82983ab03e315e333](https://etherscan.io/tx/0xc3cb3b518f455144d153e6d086b8688d6678b7318ab928b82983ab03e315e333)
>
> ```json theme={null}
> {
>   "msg.sender": "0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168",
>   "func": "execute",
>   "args": {
>     "order": [
>       {
>         "order": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000065c529c20000000000000000000000000000000000000000000000000000000065c529fe000000000000000000000000d198fbe60c49d4789525fc54567447518c7d2a110000000000000000000000000000000000000000000000000000000000000064000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000000000000000000000000083f4b3a5432fac844d000000000000000000000000000000000000000000000083f4b3a5432fac844d00000000000000000000000000000000000000000000000000000000000002000000000000000000000000006000da47483062a0d734ba3dc7576ce6a0b645c400000000000000000000000045fabb434124afaa123eeee19cea29b5e0e3dd0b04683207312f3edb79be915765c1d5b7529ef4a9500dbe0e667c9878fe7bce010000000000000000000000000000000000000000000000000000000065c52a0a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057a57e7d2199140000000000000000000000000000000000000000000000000052ff507e7c84afc00000000000000000000000045fabb434124afaa123eeee19cea29b5e0e3dd0b",
>         "sig": "0x4f210fdb1808d4ca777960ff781ceecc37f4362605fa241216ec85f201f3d244179158351a0a2d2e5ba9a2d42c4bf647ac6bcf46216d10863644cb31ea42eef31c"
>       }
>     ]
>   },
>   "return": []
> }
> ```

> [tab] Decoded Orders
>
> We code the order into the following JSON format
>
> ![](https://mintcdn.com/allium-e770e2b7/ZIDPd7nY5IQzB_F9/images/image-historical-evm-ethereum-dex-uniswap.avif?fit=max\&auto=format\&n=ZIDPd7nY5IQzB_F9\&q=85\&s=694e88322f6a1c84af0b74d1692dd639)
>
> This reflects a 1inch > ETH order
>
> ```json theme={null}
> {
>   "decayEndTime": 1707420158,
>   "decayStartTime": 1707420098,
>   "exclusiveFiller": "0xd198fbe60c49d4789525fc54567447518c7d2a11",
>   "exclusivityOverrideBps": 100,
>   "input": {
>     "endAmount": "2434156092330018112589",
>     "startAmount": "2434156092330018112589",
>     "token": "0x111111111117dc0aa78b770fa6a738034120c302"
>   },
>   "orders": {
>     "additionalValidationContract": "0x0000000000000000000000000000000000000000",
>     "additionalValidationData": "",
>     "deadline": 1707420170,
>     "nonce": 1.993348770286722e+75,
>     "reactor": "0x6000da47483062a0d734ba3dc7576ce6a0b645c4",
>     "swapper": "0x45fabb434124afaa123eeee19cea29b5e0e3dd0b"
>   },
>   "outputs": [
>     {
>       "endAmount": 373786708397280000,
>       "recipient": "0x45fabb434124afaa123eeee19cea29b5e0e3dd0b",
>       "startAmount": 394724570522292540,
>       "token": "0x0000000000000000000000000000000000000000"
>     }
>   ]
> }
> ```
