Tokens & markets6 min read

DEX Trade Data and OHLCV: Swaps, Pools and Candles

Turn swap observations into scoped market data while retaining the differences between trades, liquidity and chart aggregates.

Two contrasting glass asset forms share a frame on layered sage platforms.

Overview

When translating these concepts into an integration, keep the scope described by the wallet history api with the result. The examples in wallet transaction history and smart contract event logs show how the same distinction affects neighbouring data questions.

DEX trade data describes activity in on-chain markets. Applications use it for recent swaps, liquidity views and token price charts. Each view starts from a selected set of observations and adds its own interpretation rules.

A chart candle is not a network record by itself. It is an aggregate over included trades within a time bucket. A useful integration preserves market identities, quantity units and interval policy so the dashboard or analytical export can explain exactly which question the aggregate answers and what remains outside its scope.

Identify the pool before comparing prices

A token can trade in several pools, against different assets and under different protocol versions. Keep the network, pool reference, pair orientation and applicable market context with each observation. Symbols alone cannot distinguish those markets.

If the application combines pools into one token-level price, it needs a separate aggregation rule. Retain original observations beneath the combined result. The Uniswap swap documentation provides protocol context; a general integration still needs to state which particular markets and record types its analysis includes. A label such as token price should not hide a change in market selection or the settlement asset being measured.

Separate routed swaps from transaction grouping

One user action can traverse several pools. Its transaction may contain multiple swap observations and intermediate movements. Counting every pool interaction as a separate user trade differs from counting the overall routed action. Both views need explicit labels.

Preserve stable technical identities, then add a documented grouping layer for activity-level presentation. Keep intermediate assets and fees distinguishable. A synthetic route can exchange A through B into C. Inspect whether the application reports pool-level volume, the final user exchange or both. Repeated retrieval should not duplicate a swap, while grouping should not erase the observations needed to reconstruct the route and explain how its final amounts were derived.

Define OHLCV as an interval calculation

Open, high, low and close summarize included price observations within a chosen bucket. Volume also needs a unit and inclusion rule: base quantity, quote quantity and a converted reporting value are different series. Keep these definitions next to the chart contract.

Declare boundaries, timezone and ordering, including a tie-breaker for observations with the same displayed time. A synthetic ordered sequence of prices 2, 3 and 2.5 has open 2, high 3, low 2 and close 2.5. Retain enough references to reproduce that aggregate. A revised decoder, filter or ordering rule can change a candle without any new trade occurring in the interval.

Distinguish a quiet market from missing observations

An empty bucket can mean no included trades, an unprocessed range or an unavailable input. Those conditions should not imply the same market behavior. State whether the display leaves a gap, carries a previous close as a presentation convention or shows another documented condition.

Keep a carried-forward value separate from an observed trade. Do not manufacture volume for an interval without accepted swaps. Test a quiet interval between active buckets and another interval whose retrieval failed. The chart and export should preserve their difference. Downstream analysts can then choose a suitable handling policy instead of inheriting an invisible assumption that every missing interval had the same price or no activity.

Read liquidity using the protocol position model

A pool balance, a position's active liquidity and an executable quote are different measures. Protocol versions and position ranges can change how the pool state relates to a proposed trade. Name the quantity that a field actually measures.

The Uniswap v3 overview provides context for concentrated liquidity. A general market page should preserve its observation boundary and calculation scope. Avoid turning one balance-based headline into a promise of execution quality. Keep market state and trade-size assumptions available when presenting an estimated outcome. An unresolved component should remain visible rather than being flattened into one universal liquidity number that implies more than the inputs establish.

Validate chart aggregates against included swaps

Choose a bounded market interval and compare its candle with retained observations. Verify asset orientation, exact quantities, ordering and the selected volume unit. Reversing a pair without changing its interpretation can create a plausible but incorrectly labeled series.

Test repeated retrieval, a routed transaction, a missing interval and a market with few observations. Retain calculation versions when grouping or decoding changes. Readers should be able to move from a chart bucket to its supporting records. Keep the analytical series separate from an executable trade request or an investment conclusion. This makes a price chart useful for exploration without hiding its market scope, completeness boundaries or calculation decisions behind a visually smooth line.

Questions about the topic

Frequently asked questions

Does one swap transaction equal one pool trade?

Not necessarily. Routed transactions can interact with several pools. Preserve individual observations and document any grouping into a user-level action or combined trading volume.

What unit does OHLCV volume use?

It depends on the declared series: base quantity, quote quantity and a converted reporting value are different measures. Label the unit and retain its calculation inputs.

Should a data gap display a zero price?

No. Distinguish missing observations from an interval without accepted trades. A carry-forward display convention should remain separate from actual observed prices and trade volume.

Standards & technical documentation

Further reading

{{TODO: author name}}

Practical explanations of blockchain data, software integration and the context behind a record.

About Indexbase
← Back to all articles

Build with better context.

Get an update when private beta opens.

Form setup in progress. Nothing entered here is sent or saved. {{TODO: endpoint}} See the full form and email alternative.