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

# perpetualprotocol_v2_optimism

> Tables in tt-contracts.perpetualprotocol_v2_optimism

## Tables

### ClearingHouse\_PositionChanged\_event

Position change events from Perpetual Protocol V2 ClearingHouse contract on Optimism, capturing perpetual futures trades with trader addresses, base tokens, position sizes, notional values, fees, and realized profit/loss. Used for analyzing trading activity, fee generation, and individual trader position movements across different perpetual markets.

<Accordion title="Columns">
  | Column                         | Type        | Description                                                                                                                                                                                                                                                      |
  | ------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `block_timestamp`              | `TIMESTAMP` | Timestamp when the block was produced. UTC timezone, millisecond precision.                                                                                                                                                                                      |
  | `block_number`                 | `INT64`     | Sequential identifier for the block in which the event or transaction was recorded. Integer value indicating the block's position in the blockchain.                                                                                                             |
  | `transaction_hash`             | `STRING`    | Unique identifier for the transaction. 66-character hex string including 0x prefix.                                                                                                                                                                              |
  | `log_index`                    | `INT64`     | Position of the event within the block's transaction logs. Zero-indexed integer representing the sequential order of log emission.                                                                                                                               |
  | `address`                      | `STRING`    | Contract address that emitted the event. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                                          |
  | `removed`                      | `BOOL`      | Boolean flag indicating whether the event log was removed from the blockchain due to a chain reorganization.                                                                                                                                                     |
  | `in_trader`                    | `STRING`    | Address that initiated or executed the trade transaction. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                         |
  | `in_baseToken`                 | `STRING`    | Contract address of the base token in a trading pair. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                             |
  | `in_exchangedPositionSize`     | `STRING`    | Signed change in the trader's position size denominated in the base token, where negative values indicate short positions or position decreases. Values are in wei (smallest unit), representing the actual token amount traded in this position change event.   |
  | `in_exchangedPositionNotional` | `STRING`    | Notional value in USD of the perpetual position that was exchanged in this trade, denominated in the protocol's base unit (wei). Represents the dollar-equivalent size of the position change before fees.                                                       |
  | `in_fee`                       | `STRING`    | Fee amount charged for the transaction or operation. String-encoded integer value representing the fee in the smallest unit of the relevant token or currency.                                                                                                   |
  | `in_openNotional`              | `STRING`    | Cumulative notional value of the trader's open position after this position change event. Denominated in the quote currency (typically USD) with 18 decimal precision.                                                                                           |
  | `in_realizedPnl`               | `STRING`    | Realized profit or loss from the position or transaction. String-encoded integer value representing the net financial result in the smallest unit of the relevant token or currency, where negative values indicate losses and positive values indicate profits. |
  | `in_sqrtPriceAfterX96`         | `STRING`    | Square root of the price after the position change in Q96 fixed-point format (price multiplied by 2^96). Used in Uniswap v3-style pricing for Perpetual Protocol's virtual AMM calculations.                                                                     |
</Accordion>

<Accordion title="Sample Data">
  | in\_fee            | address                                    | removed | in\_trader                                 | log\_index | block\_number | in\_baseToken                              | in\_realizedPnl | block\_timestamp         | in\_openNotional        | transaction\_hash                                                  | in\_sqrtPriceAfterX96           | in\_exchangedPositionSize | in\_exchangedPositionNotional |
  | ------------------ | ------------------------------------------ | ------- | ------------------------------------------ | ---------- | ------------- | ------------------------------------------ | --------------- | ------------------------ | ----------------------- | ------------------------------------------------------------------ | ------------------------------- | ------------------------- | ----------------------------- |
  | 282363503553782681 | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x0136e94a86328c4a4108e51cf078b54314b6fbb0 | 190        | 114006792     | 0xb6599bd362120dc70d48409b8a08888807050700 | 0               | 2023-12-26T17:39:21.000Z | 17384886400672743261778 | 0x39df4914acbe9b79bb3b372ca603d0f07f9b88517cce4858b8fb9a058c0e7137 | 1354597618486914800600763164272 | -964167419708029771       | 282363503553782680896         |
  | 229567505467849302 | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x0136e94a86328c4a4108e51cf078b54314b6fbb0 | 268        | 114006798     | 0xb6599bd362120dc70d48409b8a08888807050700 | 0               | 2023-12-26T17:39:33.000Z | 17614224338635124713579 | 0x22be85314f1b66fd6c559612c958b51d2000e8ccc79b134a1185521fb895a076 | 1349071070678868901284003759307 | -790589594948674970       | 229567505467849301103         |
  | 129103081367369313 | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x0136e94a86328c4a4108e51cf078b54314b6fbb0 | 181        | 113985080     | 0xb6599bd362120dc70d48409b8a08888807050700 | 0               | 2023-12-26T05:35:37.000Z | 14003554018960448257749 | 0x933b3a46e108a1cb033a95c4cd01bc438fc708a6953351c46c263fcd272f42c3 | 1293625357480351129297575720338 | -483727340615237483       | 129103081367369312172         |
</Accordion>

<Accordion title="Example Query">
  **Query with partition filter**

  ```sql theme={null}
  SELECT *
  FROM `tt-contracts.perpetualprotocol_v2_optimism.ClearingHouse_PositionChanged_event`
  WHERE block_timestamp >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
  LIMIT 100
  ```
</Accordion>

***

### ClearingHouse\_PositionLiquidated\_event

Liquidation events from Perpetual Protocol v2 on Optimism, recording forced position closures with trader and liquidator addresses, position size, notional value, and liquidation fees. Used for analyzing undercollateralized positions, liquidation profitability, and protocol risk management effectiveness.

<Accordion title="Columns">
  | Column                | Type        | Description                                                                                                                                                                                                                                                      |
  | --------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `block_timestamp`     | `TIMESTAMP` | Timestamp when the block was produced. UTC timezone, millisecond precision.                                                                                                                                                                                      |
  | `block_number`        | `INT64`     | Sequential identifier for the block in which the event or transaction was recorded. Integer value indicating the block's position in the blockchain.                                                                                                             |
  | `transaction_hash`    | `STRING`    | Unique identifier for the transaction. 66-character hex string including 0x prefix.                                                                                                                                                                              |
  | `log_index`           | `INT64`     | Position of the event within the block's transaction logs. Zero-indexed integer representing the sequential order of log emission.                                                                                                                               |
  | `address`             | `STRING`    | Contract address that emitted the event. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                                          |
  | `removed`             | `BOOL`      | Boolean flag indicating whether the event log was removed from the blockchain due to a chain reorganization.                                                                                                                                                     |
  | `in_trader`           | `STRING`    | Address that initiated or executed the trade transaction. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                         |
  | `in_baseToken`        | `STRING`    | Contract address of the base token in a trading pair. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                             |
  | `in_positionNotional` | `STRING`    | Notional value of the liquidated position in USD terms at the time of liquidation, represented as a wei-denominated integer (divide by 1e18 for decimal value). Values typically range from tens to thousands of dollars based on position size and asset price. |
  | `in_positionSize`     | `STRING`    | Total size of the trading position after the event. String-encoded integer value representing the position magnitude in the smallest unit of the relevant asset or USD-denominated value.                                                                        |
  | `in_liquidationFee`   | `STRING`    | Fee paid to the liquidator for executing the position liquidation, denominated in the protocol's quote token. Value is in wei (18 decimal precision), typically representing a percentage of the liquidated position's notional value.                           |
  | `in_liquidator`       | `STRING`    | Address of the account executing the liquidation operation. Hex-encoded, 0x-prefixed, 42-character string.                                                                                                                                                       |
</Accordion>

<Accordion title="Sample Data">
  | address                                    | removed | in\_trader                                 | log\_index | block\_number | in\_baseToken                              | in\_liquidator                             | block\_timestamp         | in\_positionSize      | transaction\_hash                                                  | in\_liquidationFee   | in\_positionNotional   |
  | ------------------------------------------ | ------- | ------------------------------------------ | ---------- | ------------- | ------------------------------------------ | ------------------------------------------ | ------------------------ | --------------------- | ------------------------------------------------------------------ | -------------------- | ---------------------- |
  | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x2ccde611a35aa395c8aeb2babb4e25c835ca1760 | 11         | 92616848      | 0x9482aafdced6b899626f465e1fa0cf1b1418d797 | 0x179b2b7f339b3c1234ebac752eb8017441af90db | 2023-04-20T16:59:04.000Z | 284563341210482415406 | 0x82225d99d3ddbcb4b8021f3d576838267b891993f49e3d603832a36d3657fdcb | 5416049057588661530  | 216641962303546461209  |
  | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x6c2f2ea95392f22d138be349061bd55e18e0d946 | 11         | 92606754      | 0x5a7ed3ce6096228a9fe1b673830e6a78c9cfb71b | 0x179b2b7f339b3c1234ebac752eb8017441af90db | 2023-04-20T16:08:00.000Z | 709084252083590873649 | 0x58c543816361560091133393db0d567a67fb38b9b4b124c050193a9a008f3260 | 43520596231774216847 | 1740823849270968673890 |
  | 0x82ac2ce43e33683c58be4cdc40975e73aa50f459 | false   | 0x2ca0f9dba9780ddceb4921a2d895d32b6855f3a8 | 11         | 92604636      | 0xbe5de48197fc974600929196239e264ecb703ee8 | 0x179b2b7f339b3c1234ebac752eb8017441af90db | 2023-04-20T16:02:59.000Z | 111774458301385969416 | 0xd89e6aa16fa18c416379b51ec9102108cd849714f591c013f2c8308b174224d6 | 2956152074682252875  | 118246082987290115012  |
</Accordion>

<Accordion title="Example Query">
  **Query with partition filter**

  ```sql theme={null}
  SELECT *
  FROM `tt-contracts.perpetualprotocol_v2_optimism.ClearingHouse_PositionLiquidated_event`
  WHERE block_timestamp >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
  LIMIT 100
  ```
</Accordion>

***

### PerpLiquidityMining\_Claimed\_event

Liquidity mining reward claim events from Perpetual Protocol V2 on Optimism, recording when liquidity providers withdraw their earned incentives. Tracks claimant addresses and claimed token balances (in wei) for analyzing LP reward distribution and participant behavior.

<Accordion title="Columns">
  | Column             | Type        | Description                                                                                                                                          |
  | ------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `block_timestamp`  | `TIMESTAMP` | Timestamp when the block was produced. UTC timezone, millisecond precision.                                                                          |
  | `block_number`     | `INT64`     | Sequential identifier for the block in which the event or transaction was recorded. Integer value indicating the block's position in the blockchain. |
  | `transaction_hash` | `STRING`    | Unique identifier for the transaction. 66-character hex string including 0x prefix.                                                                  |
  | `log_index`        | `INT64`     | Position of the event within the block's transaction logs. Zero-indexed integer representing the sequential order of log emission.                   |
  | `address`          | `STRING`    | Contract address that emitted the event. Hex-encoded, 0x-prefixed, 42-character string.                                                              |
  | `removed`          | `BOOL`      | Boolean flag indicating whether the event log was removed from the blockchain due to a chain reorganization.                                         |
  | `in__claimant`     | `STRING`    | Address of the account claiming the tokens or rewards. Hex-encoded, 0x-prefixed, 42-character string.                                                |
  | `in__balance`      | `STRING`    | Token amount represented in smallest denomination. String-encoded integer value without decimal places.                                              |
</Accordion>

<Accordion title="Sample Data">
  | address                                    | removed | log\_index | in\_\_balance         | block\_number | in\_\_claimant                             | block\_timestamp         | transaction\_hash                                                  |
  | ------------------------------------------ | ------- | ---------- | --------------------- | ------------- | ------------------------------------------ | ------------------------ | ------------------------------------------------------------------ |
  | 0x3230cbb08c64d0804be5b7f4ce43834291490a91 | false   | 0          | 18986797060401900000  | 3228672       | 0x432fcd67815d5cc72808a7815a02373fdee7d740 | 2022-02-05T07:39:45.000Z | 0x28fa2503d7b7d58e03d7f501f3512403bf81449334889d205ff73d3ca1794769 |
  | 0x3230cbb08c64d0804be5b7f4ce43834291490a91 | false   | 0          | 829655136245994420000 | 26415459      | 0x571e41f85369574c6232439de6434b30dccf2209 | 2022-09-30T07:29:17.000Z | 0x41be8fbc2395081f5b80b125d84a1fcf813ba9b6d2128e165819673adcbc6057 |
  | 0x3230cbb08c64d0804be5b7f4ce43834291490a91 | false   | 0          | 21881044493590009000  | 26375108      | 0xbe29499bc8dc2b426853642bae13e5f91d0fcc5a | 2022-09-30T02:57:47.000Z | 0x3874247e0a7b18e958d0faa7ef4622fe44915f9062e07ef1f553b60fdff76202 |
</Accordion>

<Accordion title="Example Query">
  **Query with partition filter**

  ```sql theme={null}
  SELECT *
  FROM `tt-contracts.perpetualprotocol_v2_optimism.PerpLiquidityMining_Claimed_event`
  WHERE block_timestamp >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
  LIMIT 100
  ```
</Accordion>

***
