DEXPools Cube on EVM Chains
This section explains how the dexpool data is built and shared via APIs and Kafka streams. It also explains how to understand each entry of the response.
Note: In GraphQL, DEXPools data is accessed through two schema cubes:
DEXPoolEvents: Provides pool event data (swaps, mints, burns, etc.)DEXPoolSlippages: Provides slippage and price impact data for different trade sizes
Concept Explanation
Liquidity pools are fundamental components of decentralized exchanges that enable token swaps without traditional order books. Each pool contains two tokens (CurrencyA and CurrencyB), and the ratio of these tokens determines the exchange rate.
When a user wants to swap tokens, they interact with a liquidity pool. The pool calculates the output amount based on:
- Current liquidity reserves
- The amount being swapped
- Price impact and slippage tolerance
For example, if you want to sell ANKR tokens for WETH in a pool:
Pool: 0x13dc0a39dc00f394e030b97b0b569dedbe634c0d
DEX: uniswap_v3 (3)
Token0: ANKR (decimals: 18)
Token1: WETH (decimals: 18)
Liquidity: 604099.111169 ANKR, 1.074933 WETH
Direction: Sell ANKR → Buy WETH
slippage: 0.1%, MaxIn: 205.504593 ANKR, MinOut: 0.000434 WETH, ratio: 473132.526201 ANKR/WETH
slippage: 0.5%, MaxIn: 997.299766 ANKR, MinOut: 0.002097 WETH, ratio: 475456.664617 ANKR/WETH
slippage: 1.0%, MaxIn: 2012.776732 ANKR, MinOut: 0.004205 WETH, ratio: 478581.192432 ANKR/WETH
slippage: 2.0%, MaxIn: 4067.602247 ANKR, MinOut: 0.008289 WETH, ratio: 490722.489031 ANKR/WETH
slippage: 5.0%, MaxIn: 10501.563247 ANKR, MinOut: 0.020650 WETH, ratio: 508535.330236 ANKR/WETH
slippage: 10.0%, MaxIn: 22396.241185 ANKR, MinOut: 0.040771 WETH, ratio: 549306.392584 ANKR/WETH
If you are willing to accept a price impact and slippage of up to 10.0% against the current spot price, you can sell a maximum of 22396.241185 ANKR into the pool. In return, you are guaranteed to receive at least 0.040771 WETH. The average execution price for this trade would be approximately 549306.392584 ANKR per 1 WETH.
The calculation considers the price impact plus the worst-case scenario of slippage for different amounts, with limited losses for each, by simulating a swap by iterating through initialized ticks in the TickBitmap.
Important note: The liquidity calculation differs by protocol version:
- For Uniswap V2 and V3, liquidity reflects exactly the balance of the pool
- For Uniswap V4, liquidity is the token balances in PoolManager
Understanding Pool Structure
In DEXPools, each pool is represented with several key components:
Pool: The pool smart contract address and token pair informationDex: The DEX protocol details (name, version, family)Liquidity: Current token reserves in the poolPoolPriceTable: Price calculations for different slippage tolerances in both directions