query V3Pool($chain: Chain!, $address: String!) {
  v3Pool(chain: $chain, address: $address) {
    id
    protocolVersion
    address
    feeTier
    token0 {
      ...SimpleTokenDetails
      project {
        id
        markets(currencies: [USD]) {
          id
          price {
            id
            value
          }
        }
        logo {
          id
          url
        }
      }
    }
    token0Supply
    token1 {
      ...SimpleTokenDetails
      project {
        id
        markets(currencies: [USD]) {
          id
          price {
            id
            value
          }
        }
        logo {
          id
          url
        }
      }
    }
    token1Supply
    txCount
    volume24h: cumulativeVolume(duration: DAY) {
      value
    }
    historicalVolume(duration: WEEK) {
      value
      timestamp
    }
    totalLiquidity {
      value
    }
    totalLiquidityPercentChange24h {
      value
    }
  }
}

query V4Pool($chain: Chain!, $poolId: String!) {
  v4Pool(chain: $chain, poolId: $poolId) {
    id
    protocolVersion
    feeTier
    poolId
    hook {
      id
      address
    }
    token0 {
      ...SimpleTokenDetails
      project {
        id
        markets(currencies: [USD]) {
          id
          price {
            id
            value
          }
        }
        logo {
          id
          url
        }
      }
    }
    token0Supply
    token1 {
      ...SimpleTokenDetails
      project {
        id
        markets(currencies: [USD]) {
          id
          price {
            id
            value
          }
        }
        logo {
          id
          url
        }
      }
    }
    token1Supply
    txCount
    volume24h: cumulativeVolume(duration: DAY) {
      value
    }
    historicalVolume(duration: WEEK) {
      value
      timestamp
    }
    totalLiquidity {
      value
    }
    totalLiquidityPercentChange24h {
      value
    }
  }
}

query PoolPriceHistory($chain: Chain!, $addressOrId: String!, $duration: HistoryDuration!, $isV4: Boolean!, $isV3: Boolean!, $isV2: Boolean!) {
  v4Pool(chain: $chain, poolId: $addressOrId)
  @include (if: $isV4) {
    id
    priceHistory(duration: $duration) {
      id
      token0Price
      token1Price
      timestamp
    }
  }
  v3Pool(chain: $chain, address: $addressOrId) 
  @include (if: $isV3) {
    id
    priceHistory(duration: $duration) {
      id
      token0Price
      token1Price
      timestamp
    }
  }
  v2Pair(chain: $chain, address: $addressOrId)
  @include (if: $isV2) {
    id
    priceHistory(duration: $duration) {
      id
      token0Price
      token1Price
      timestamp
    }
  }
}

query PoolVolumeHistory($chain: Chain!, $addressOrId: String!, $duration: HistoryDuration!, $isV4: Boolean!, $isV3: Boolean!, $isV2: Boolean!) {
  v4Pool(chain: $chain, poolId: $addressOrId) 
  @include (if: $isV4) {
    id
    historicalVolume(duration: $duration) {
      id
      value
      timestamp
    }
  }
  v3Pool(chain: $chain, address: $addressOrId) 
  @include (if: $isV3) {
    id
    historicalVolume(duration: $duration) {
      id
      value
      timestamp
    }
  }
  v2Pair(chain: $chain, address: $addressOrId) 
  @include (if: $isV2) {
    id
    historicalVolume(duration: $duration) {
      id
      value
      timestamp
    }
  }
}

query V2Pair($chain: Chain!, $address: String!) {
  v2Pair(chain: $chain, address: $address) {
    id
    protocolVersion
    address
    token0 {
      ...SimpleTokenDetails
      project {
        id
        markets(currencies: [USD]) {
          id
          price {
            id
            value
          }
        }
        logo {
          id
          url
        }
      }
    }
    token0Supply
    token1 {
      ...SimpleTokenDetails
      project {
    id
    markets(currencies: [USD]) {
      id
      price {
        id
        value
      }
    }
    logo {
      id
      url
    }
  }
    }
    token1Supply
    txCount
    volume24h: cumulativeVolume(duration: DAY) {
      value
    }
    historicalVolume(duration: WEEK) {
      value
      timestamp
    }
    totalLiquidity {
      value
    }
    totalLiquidityPercentChange24h {
      value
    }
  }
}
