Average Price

The average price is the volume weighted average of a token based on all the recorded swaps on a network during a a given time period.

The average price of a token is calculated by taking the sum of the product of each individual trade's price and volume, divided by the total volume of all trades during a given time period. This volume-weighted average reflects the impact of larger trades on the overall price of the token.

Average Price Response Format

Format:

FieldData TypeDescription
timestringThe date and time corresponding the start of the period for which the average price was calculated, in ISO 8601 format
pricestringThe average price for the given time period (daily or hourly)
volumestringThe USD volume of tokens for the given time period (eg. daily or hourly volume)

Example response:

{
    "statusCode": 200,
    "status": true,
    "data": [
        {
            "time": "2022-12-06T05:00:00.000Z",
            "price": "1.000072230000000011685",
            "volume": "1166211.59150384060621251"
        },
        {
            "time": "2022-12-06T04:00:00.000Z",
            "price": "0.999842841730769643205",
            "volume": "230545.1954238749146126"
        },
       ...
}

OHLCV

OHLCV (open-high-low-close-volume) data is a common format for presenting the price and trading activity of a token over a specific time period. Each piece of OHLCV data includes the following information:

open: The price at which the asset opened the time period
high: The highest price the asset reached during the time period
low: The lowest price the asset reached during the time period
close: The price at which the asset closed the time period

OHLCV data can be used to visualize the range and volatility of an asset's price over time, as well as to identify patterns and trends in its trading activity.

As with other endpoints all timestamps are UTC. So the open price is the price of the first trade after 00:00:00 UTC. And the close is the price of the last trade before 00:00:00 UTC.

📘

Pool OHLC

Pool OHLC candles are derived from every swap happening on a given pool.

While centralized exchanges clearly define base currencies and quote currencies for each instrument (for example in the case ETH/USDT, ETH is the base currency and USDT is the quote currency), Uniswap and most other decentralized exchanges do not define a base/quote currency. Therefore the definition of the "market price" (= amount of base currency traded/ amount of quote currency traded) is ambiguous.

For simplicity, we always define token0 as the base currency and token1 as the quote currency. This means the OHLC records are computed for the prices p = amount0 / amount1.

📘

Token OHLC

In the case of token OHLC, we aggregate every swap that includes the given tokens on either side of the swap.

The prices used to compute the token OHLC are the USD prices for each token in the swap at the time of the swap. Note that this is different from the pool OHLC data.

  • The pool OHLC endpoint returns OHLC data based on pool prices, also known as market price, where the quote currency is not necessarily USD.

  • The token OHLC endpoint returns OHLC data based on recorded USD token prices at the time of each swap. The token USD price is usually computed through a chainlink oracle. You can read more about how USD prices are calculated in the corresponding section.

OHLCV Response Format

FieldData TypeDescription
timestringThe date and time at which the OHLC (Open-High-Low-Close) data was recorded, in ISO 8601 format
timestampnumberThe Unix timestamp at which the OHLC data was recorded
openstringThe opening price for the period the OHLC data was recorded
highstringThe highest price for the period the OHLC data was recorded
lowstringThe lowest price for the period the OHLC data was recorded
closestringThe closing price for the period the OHLC data was recorded

Example response:

{
    "statusCode": 200,
    "status": true,
    "data": [
        {
            "close": "6041.655160116758",
            "high": "6041.655160116758",
            "low": "6041.655160116758",
            "open": "6041.655160116758",
            "time": "2022-11-15T00:00:00.000Z",
            "timestamp": 1668470400,
            "volumefrom": "887.8247305667171",
            "volumeto": "4725.4308145439794"
        },
        ....
       ]
}