# DEX

Key Tables:

* **Pools**: Details of liquidity pools, including token pairs, liquidity provided, and fee rates.
* **LP Position Snapshot**: Snapshots of liquidity provider positions, tracking token amounts and USD values.
* **Pool Snapshot**: Snapshot of individuals pools, including token volume, fees, and transaction data.
* **Trades**: Records of user trades, capturing swap amounts, tokens involved, and fees.\\

{% tabs %}
{% tab title="Pools" %}

| Property                | Description                                                                                                     | Type   |
| ----------------------- | --------------------------------------------------------------------------------------------------------------- | ------ |
| chain\_id               | The standard id of the chain.                                                                                   | number |
| creation\_block\_number | The block this pool was created in.                                                                             | number |
| timestamp               | The timestamp of the block that this pool was created in.                                                       | number |
| pool\_address           | The contract address of the LP pool.                                                                            | string |
| lp\_token\_address      | The token address of the LP token for this pool.                                                                | string |
| lp\_token\_symbol       | The symbol of the LP token.                                                                                     | string |
| token\_address          | The token address of the pool token at token\_index.                                                            | string |
| token\_symbol           | The symbol of the pool token.                                                                                   | string |
| token\_decimals         | The decimals of the pool token.                                                                                 | string |
| token\_index            | The index in the pool smart contract that this token appears at, default 0 (ie, one entry per token in a pool). | number |
| fee\_rate               | The fee rate of the pool, as a percentage (ie, 2.3% as 0.023).                                                  | number |
| dex\_type               | The type of the DEX (ie, CPMM, CLMM, Orderbook).                                                                | string |
| {% endtab %}            |                                                                                                                 |        |

{% tab title="LP Position Snapshot" %}

| Property           | Description                                                                                                                                        | Type   |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp          | The timestamp of the snapshot.                                                                                                                     | number |
| block\_date        | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots).                                  | date   |
| chain\_id          | The standard id of the chain.                                                                                                                      | number |
| pool\_address      | The contract address of the pool.                                                                                                                  | string |
| user\_address      | The address of the liquidity provider.                                                                                                             | string |
| token\_index       | The token index based on the smart contract.                                                                                                       | number |
| token\_address     | The contract address of the token provided as liquidity.                                                                                           | string |
| token\_symbol      | The symbol of the token.                                                                                                                           | string |
| token\_amount      | The amount of the underlying liquidity position in the pool, decimal normalized (ie, the amount of USDC provided by the LPer in a USDC/WETH pool). | number |
| token\_amount\_usd | The amount of the token in USD.                                                                                                                    | number |
| {% endtab %}       |                                                                                                                                                    |        |

{% tab title="Pool Snapshot" %}

| Property            | Description                                                                                                       | Type   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp           | The timestamp of the snapshot.                                                                                    | number |
| block\_date         | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots). | date   |
| chain\_id           | The standard id of the chain.                                                                                     | number |
| pool\_address       | The contract address of the LP pool.                                                                              | string |
| token\_index        | The token index in the smart contract.                                                                            | number |
| token\_address      | The contract address of the token in the pool.                                                                    | string |
| token\_symbol       | The symbol of the token.                                                                                          | string |
| token\_amount       | The amount of the token in this pool at the snapshot.                                                             | number |
| token\_amount\_usd  | The amount of the token in USD.                                                                                   | number |
| volume\_amount      | The volume of the token transacted in this pool during the given snapshot, decimal normalized.                    | number |
| volume\_usd         | The volume transacted in the given snapshot, in USD.                                                              | number |
| fee\_rate           | The fee rate of the pool, as a percentage (ie, 2.3% as 0.023).                                                    | number |
| total\_fees\_usd    | The total amount of revenue and fees paid in this pool in the given snapshot, in USD.                             | number |
| user\_fees\_usd     | The amount of total fees accrued to liquidity providers of the protocol, in USD.                                  | number |
| protocol\_fees\_usd | The amount of total fees accrued to the protocol, in USD.                                                         | number |
| {% endtab %}        |                                                                                                                   |        |

{% tab title="Trades" %}

| Property                 | Description                                                                                                                                                    | Type   |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp                | The timestamp of the transaction.                                                                                                                              | number |
| chain\_id                | The standard id of the chain.                                                                                                                                  | number |
| block\_number            | The block number of the trade.                                                                                                                                 | number |
| log\_index               | The event log. For transactions that don't emit event, create arbitrary index starting from 0.                                                                 | number |
| transaction\_hash        | The hash of the transaction.                                                                                                                                   | string |
| user\_address            | The address that initiates the transaction (ie, the transaction signer).                                                                                       | string |
| taker\_address           | The taker, the address that receives the output of the swap (ie, could be the same as user\_address unless a proxy contract/router is used).                   | string |
| pair\_name               | The name of the token pair.                                                                                                                                    | string |
| pool\_address            | The contract address of the LP pool being traded in.                                                                                                           | string |
| input\_token\_address    | The contract address of the input token (ie, the tokenIn or the token being sold to the pool).                                                                 | string |
| input\_token\_symbol     | The symbol of the input token.                                                                                                                                 | string |
| input\_token\_amount     | The amount of the input token, decimal normalized.                                                                                                             | number |
| output\_token\_address   | The contract address of the output token (ie, the tokenOut of the token being bought by the user and sent to the taker).                                       | string |
| output\_token\_symbol    | The symbol of the output token.                                                                                                                                | string |
| output\_token\_amount    | The amount of the output token, decimal normalized.                                                                                                            | number |
| spot\_price\_after\_swap | The spot price in the pool after the swap is complete. This is the price ratio a user would get if they made an infinitesimal swap immediately after this one. | number |
| swap\_amount\_usd        | The amount of the swap in USD.                                                                                                                                 | number |
| fees\_usd                | The fees paid by the user.                                                                                                                                     | number |
| {% endtab %}             |                                                                                                                                                                |        |
| {% endtabs %}            |                                                                                                                                                                |        |
