# Tracked Data

### Swap

```graphql
type Swap @entity {
  # transaction hash + "#" + index in swaps Transaction array
  id: ID!
  # pointer to transaction
  transaction: Transaction!
  # timestamp of transaction
  timestamp: BigInt!
  # pool swap occured within
  pool: Pool!
  # token swap from
  token0: Token!
  # token swap to
  token1: Token!
  # sender of the swap
  sender: Bytes!
  # the EOA that initiated the txn
  origin: Bytes! 
  # delta of token0 swapped
  amount0: BigDecimal!
  # delta of token1 swapped
  amount1: BigDecimal!
  # amount of liquidity left in pool after swap
  liquidity: BigInt!
  # derived info
  amountUSD: BigDecimal!
  # The sqrt(price) of the pool after the swap, as a Q64.96
  sqrtPriceX96: BigInt!
  # the tick after the swap
  tick: BigInt!
  fee: Int!
  # index within the txn
  logIndex: BigInt
  # running sum of gas for current tx
  gasAccumulated: BigInt!
  gasInWeiAccumulated: BigInt!
}
```

### TokenDayData

```graphql
type TokenDayData @entity {
  # token address concatendated with date
  id: ID!
  # timestamp rounded to current day and divided by 86400
  date: Int!
  # pointer to the token
  token: Token!
  # volume in token units
  volume: BigDecimal!
  # volume in derived USD
  volumeUSD: BigDecimal!
  # volume in USD even on pools with less reliable USD values
  untrackedVolumeUSD: BigDecimal!
  # liquidity across all pools in token units
  totalValueLocked: BigDecimal!
  # liquidity across all pools in derived USD
  totalValueLockedUSD: BigDecimal!
  # price at end of period in USD
  priceUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # opening price USD
  open: BigDecimal!
  # high price USD
  high: BigDecimal!
  # low price USD
  low: BigDecimal!
  # close price USD
  close: BigDecimal!
}
```

### UniswapDayData

```graphql
type UniswapDayData @entity {
  # timestamp rounded to current day and divided by 86400
  id: ID!
  # timestamp rounded to current day and divided by 86400
  date: Int!
  # total daily volume in Uniswap derived in terms of ETH
  volumeETH: BigDecimal!
  # total daily volume in Uniswap derived in terms of USD
  volumeUSD: BigDecimal!
  # total daily volume in Uniswap derived in terms of USD untracked
  volumeUSDUntracked: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # number of daily transactions
  txCount: BigInt!
  # tvl in terms of USD
  tvlUSD: BigDecimal!
}
```

### PoolDayData

```graphql
type PoolDayData @entity {
  # timestamp rounded to current day and divided by 86400
  id: ID!
  # timestamp rounded to current day and divided by 86400
  date: Int!
  # pointer to pool
  pool: Pool!
  # in range liquidity at the end of a period
  liquidity: BigInt!
  # current price tracker at the end of a period
  sqrtPrice: BigInt!
  # price of token0 - derived from sqrtPrice
  token0Price: BigDecimal!
  # price of token1 - derived from sqrtPrice
  token1Price: BigDecimal!
  # current tick at the end of a period
  tick: BigInt
  # tvl derived in USD at the end of a period
  tvlUSD: BigDecimal!
  # volume in token0
  volumeToken0: BigDecimal!
  # volume in token1
  volumeToken1: BigDecimal!
  # volume in USD
  volumeUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # number of transactions during period
  txCount: BigInt!
  # opening price of token0
  open: BigDecimal!
  # high price of token0
  high: BigDecimal!
  # low price of token0
  low: BigDecimal!
  # close price of token0
  close: BigDecimal!
}
```

### PoolHourData

```graphql
type PoolHourData @entity {
  # format: <pool address>-<timestamp>
  id: ID!
  # unix timestamp for start of an hour
  periodStartUnix: Int!
  # pointer to pool
  pool: Pool!
  # in range liquidity at the end of a period
  liquidity: BigInt!
  # current price tracker at the end of a period
  sqrtPrice: BigInt!
  # price of token0 - derived from sqrtPrice
  token0Price: BigDecimal!
  # price of token1 - derived from sqrtPrice
  token1Price: BigDecimal!
  # current tick at the end of a period
  tick: BigInt
  # tvl derived in USD at the end of a period
  tvlUSD: BigDecimal!
  # volume in token0
  volumeToken0: BigDecimal!
  # volume in token1
  volumeToken1: BigDecimal!
  # volume in USD
  volumeUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # number of transactions during period
  txCount: BigInt!
  # opening price of token0
  open: BigDecimal!
  # high price of token0
  high: BigDecimal!
  # low price of token0
  low: BigDecimal!
  # close price of token0
  close: BigDecimal!
}
```

### TokenHourData

```graphql
type TokenHourData @entity {
  # token address concatendated with date
  id: ID!
  # unix timestamp for a start of an hour
  periodStartUnix: Int!
  # pointer to token
  token: Token!
  # volume in token units
  volume: BigDecimal!
  # volume in derived USD
  volumeUSD: BigDecimal!
  # volume in USD even on pools with less reliable USD values
  untrackedVolumeUSD: BigDecimal!
  # liquidity across all pools in token units
  totalValueLocked: BigDecimal!
  # liquidity across all pools in derived USD
  totalValueLockedUSD: BigDecimal!
  # price at the end of a period in USD
  priceUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # opening price USD
  open: BigDecimal!
  # high price USD
  high: BigDecimal!
  # low price USD
  low: BigDecimal!
  # close price USD
  close: BigDecimal!
}
```

### PoolManager

```graphql
type PoolManager @entity {
  # poolManager address
  id: ID!
  hookCount: BigInt!
  # amount of pools created
  poolCount: BigInt!
  # all0-time amount of transactions
  txCount: BigInt!
  # all-time total volume in derived USD
  totalVolumeUSD: BigDecimal!
  # all-time total volume in derived ETH
  totalVolumeETH: BigDecimal!
  # all-time total swap fees in USD
  totalFeesUSD: BigDecimal!
  # all-time total swap fees in USD
  totalFeesETH: BigDecimal!
  # all-time volume even through less reliable USD values
  untrackedVolumeUSD: BigDecimal!
  # TVL derived in USD
  totalValueLockedUSD: BigDecimal!
  # TVL derived in ETH
  totalValueLockedETH: BigDecimal!
  # TVL derived in USD untracked
  totalValueLockedUSDUntracked: BigDecimal!
  # TVL derived in ETH untracked
  totalValueLockedETHUntracked: BigDecimal!
  # current owner of the factory
  owner: ID!
}
```

### Pool

```graphql
type Pool @entity {
  # pool address
  id: ID!
  # creation
  createdAtTimestamp: BigInt!
  # block pool was created at
  createdAtBlockNumber: BigInt!
  # token0
  token0: Token!
  # token1
  token1: Token!
  # fee amount
  feeTier: BigInt!
  # in range liquidity
  liquidity: BigInt!
  # current price tracker
  sqrtPrice: BigInt!
  # token0 per token1
  token0Price: BigDecimal!
  # token1 per token0
  token1Price: BigDecimal!
  # current tick
  tick: BigInt
  # tick spacing
  tickSpacing: BigInt!
  # current observation index
  observationIndex: BigInt!
  # all-time token0 swapped
  volumeToken0: BigDecimal!
  # all-time token1 swapped
  volumeToken1: BigDecimal!
  # all-time USD swapped
  volumeUSD: BigDecimal!
  # all-time USD swapped, not filtered for unreliable USD pools
  untrackedVolumeUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  feesToken0: BigDecimal!
  feesToken1: BigDecimal!
  # all-time number of transactions
  txCount: BigInt!
  # all-time fees collected token0
  collectedFeesToken0: BigDecimal!
  # all-time fees collected token1
  collectedFeesToken1: BigDecimal!
  # all-time fees collected derived USD
  collectedFeesUSD: BigDecimal!
  # total token 0 across all ticks
  totalValueLockedToken0: BigDecimal!
  # total token 1 across all ticks
  totalValueLockedToken1: BigDecimal!
  # TVL in derived ETH
  totalValueLockedETH: BigDecimal!
  # TVL in USD
  totalValueLockedUSD: BigDecimal!
  # TVL derived in USD untracked
  totalValueLockedUSDUntracked: BigDecimal!
  # Fields used to help relate derivatives
  liquidityProviderCount: BigInt! # used to detect new exchanges
  # hourly snapshots of pool data
  poolHourData: [PoolHourData!]! @derivedFrom(field: "pool")
  # daily snapshots of pool data
  poolDayData: [PoolDayData!]! @derivedFrom(field: "pool")
  hookAddress: Bytes!
  # hook address
  hook: Hook!

  gasAccumulatedBySwaps: BigInt!
  gasAccumulatedByModifyLiqs: BigInt!
  gasAccumulatedBySwapsInEth: BigInt!
  gasAccumulatedByModifyLiqsInEth: BigInt!

  swapsCount: BigInt!
  addLiqCount: BigInt!
  removeLiqCount: BigInt!

  lastTx: String

  # derived fields
  modifyLiquidities: [ModifyLiquidity!]! @derivedFrom(field: "pool")
  swaps: [Swap!]! @derivedFrom(field: "pool")
  ticks: [Tick!]! @derivedFrom(field: "pool")
}
```

### Token

```graphql
type Token @entity {
  # token address
  id: ID!
  # token symbol
  symbol: String!
  # token name
  name: String!
  # token decimals
  decimals: BigInt!
  # token total supply
  totalSupply: BigInt!
  # volume in token units
  volume: BigDecimal!
  # volume in derived USD
  volumeUSD: BigDecimal!
  # volume in USD even on pools with less reliable USD values
  untrackedVolumeUSD: BigDecimal!
  # fees in USD
  feesUSD: BigDecimal!
  # transactions across all pools that include this token
  txCount: BigInt!
  # number of pools containing this token
  poolCount: BigInt!
  # liquidity across all pools in token units
  totalValueLocked: BigDecimal!
  # liquidity across all pools in derived USD
  totalValueLockedUSD: BigDecimal!
  # TVL derived in USD untracked
  totalValueLockedUSDUntracked: BigDecimal!
  # Note: for chains where ETH is not the native token, this will be the derived
  # price of that chain's native token, effectively, this should be renamed
  # derivedNative
  derivedETH: BigDecimal!
  # pools token is in that are white listed for USD pricing
  whitelistPools: [Pool!]!
  # derived fields
  tokenDayData: [TokenDayData!]! @derivedFrom(field: "token")
}
```

### Bundle

```graphql
type Bundle @entity {
  id: ID!
  # price of ETH in usd
  ethPriceUSD: BigDecimal!
}
```

### Hook

```graphql
type Hook @entity {
  id: ID!
  address: Bytes!
  deployedAtTimestamp: BigInt!
  deployedAtBlocknumber: BigInt!
  txHash: Bytes!
  deployer: Bytes!

  # all time USD swapped
  volumeUSD: BigDecimal!
  # all time USD swapped, unfiltered for unreliable USD pools
  untrackedVolumeUSD: BigDecimal!

  # fees in USD
  feesUSD: BigDecimal!
  # all time fees collected derived USD
  collectedFeesUSD: BigDecimal!
  
  # tvl derived ETH
  totalValueLockedETH: BigDecimal!
  # tvl USD
  totalValueLockedUSD: BigDecimal!
  # TVL derived in USD untracked
  totalValueLockedUSDUntracked: BigDecimal!
  
  gasAccumulatedBySwaps: BigInt!
  gasAccumulatedByModifyLiqs: BigInt!
  gasAccumulatedBySwapsInEth: BigInt!
  gasAccumulatedByModifyLiqsInEth: BigInt!

  swapsCount: BigInt!
  addLiqCount: BigInt!
  removeLiqCount: BigInt!

  pools: [Pool!]! @derivedFrom(field: "hook")
}
```

### PositionManager

```graphql
type PositionManager @entity {
  id: ID!
  lastTx: Bytes
  lastLogIndex: BigInt
  lastTokenId: String
}
```

### Position

```graphql
type Position @entity {
  # tokenId
  id: ID!
  #TODO:
  poolId: String!
  liquidity: BigInt!
  # lower tick of the position
  tickLower: BigInt!
  # upper tick of the position
  tickUpper: BigInt!
  # tokenId
  tokenId: BigInt!
  # address of current owner
  owner: String!
  # the EOA that minted the position
  origin: String!
  # created time
  createdAtTimestamp: BigInt!
  # subscribe events
  subscriptions: [Subscribe!]! @derivedFrom(field: "position")
  # unsubscription events
  unsubscriptions: [Unsubscribe!]! @derivedFrom(field: "position")
  # transfer events
  transfers: [Transfer!]! @derivedFrom(field: "position")
}
```

### Transfer

```graphql
type Transfer @entity {
  # transaction hash + '-' + log index
  id: ID!
  # token id of position
  tokenId: BigInt!
  # address of previous owner
  from: String!
  # address of new owner
  to: String!
  # pointer to transaction
  transaction: Transaction!
  # log index
  logIndex: BigInt!
  # time of tx
  timestamp: BigInt!
  # the EOA that initiated the tx
  origin: String!
  # pointer to position
  position: Position!
}
```

### ModifyLiquidity

```graphql
type ModifyLiquidity @entity {
  # transaction hash + "#" + index in mints Transaction array
  id: ID!
  # which txn the ModifyLiquidity was included in
  transaction: Transaction!
  # time of txn
  timestamp: BigInt!
  # pool position is within
  pool: Pool!
  # allow indexing by tokens
  token0: Token!
  # allow indexing by tokens
  token1: Token!
  # the address that modified the liquidity
  sender: Bytes
  # txn origin
  origin: Bytes! # the EOA that initiated the txn
  # amount of liquidity modified
  amount: BigInt!
  # amount of token 0 modified
  amount0: BigDecimal!
  # amount of token 1 modified
  amount1: BigDecimal!
  # derived amount based on available prices of tokens
  amountUSD: BigDecimal
  # lower tick of the position
  tickLower: BigInt!
  # upper tick of the position
  tickUpper: BigInt!
  salt: Bytes!
  #TODO:
  covertedSalt: String!
  # index within the txn
  logIndex: BigInt
  gasAccumulated: BigInt!
  gasInWeiAccumulated: BigInt!
}
```

### Tick

```graphql
type Tick @entity {
  # format: <pool address>#<tick index>
  id: ID!
  # pool address
  poolAddress: String
  # tick index
  tickIdx: BigInt!
  # pointer to pool
  pool: Pool!
  # total liquidity pool has as tick lower or upper
  liquidityGross: BigInt!
  # how much liquidity changes when tick crossed
  liquidityNet: BigInt!
  # calculated price of token0 of tick within this pool - constant
  price0: BigDecimal!
  # calculated price of token1 of tick within this pool - constant
  price1: BigDecimal!
  # created time
  createdAtTimestamp: BigInt!
  # created block
  createdAtBlockNumber: BigInt!
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hookrank.gitbook.io/hookrank/hookrank-indexing/tracked-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
