Ethereum Slippage API
In this section we will see how to get Ethereum DEX pool slippage information using our API. The slippage API helps you understand price impact and liquidity depth for token swaps on Ethereum DEX pools.
Understanding Slippage and Price Impact
Slippage refers to the difference between the expected price of a trade and the actual execution price. When swapping tokens in a DEX pool, larger trades can move the price due to limited liquidity, resulting in slippage.
The DEXPoolSlippages API provides detailed information about:
- Maximum input amounts that can be swapped at different slippage tolerances
- Minimum output amounts guaranteed at each slippage level
- Average execution prices for different trade sizes
- Price impact calculations for both swap directions (A to B and B to A)
For a comprehensive explanation of how DEX pools work, liquidity calculations, and price tables, refer to the DEXPools Cube documentation.
Realtime Slippage Monitoring
This subscription query returns real-time slippage data for all DEX pools on Ethereum. You can monitor price impact and liquidity depth as trades occur.
You can find the query here
subscription {
EVM(network: eth) {
DEXPoolSlippages {
Price {
BtoA {
Price
MinAmountOut
MaxAmountIn
}
AtoB {
Price
MinAmountOut
MaxAmountIn
}
Pool {
PoolId
SmartContract
Pair {
Decimals
SmartContract
Name
}
CurrencyB {
Symbol
SmartContract
Name
Decimals
}
CurrencyA {
Symbol
SmartContract
Name
Decimals
}
}
Dex {
SmartContract
ProtocolVersion
ProtocolName
ProtocolFamily
}
SlippageBasisPoints
}
Block {
Time
Number
}
}
}
}
Latest Slippage for a Specific Pool on Uniswap V3
This query retrieves the latest slippage data for a specific DEX pool on Ethereum. Use this to check current liquidity depth and price impact for a particular token pair.
You can find the query here
query {
EVM(network: eth) {
DEXPoolSlippages(
where: {Price: {Pool: {SmartContract: {is: "0xa43fe16908251ee70ef74718545e4fe6c5ccec9f"}}}}
limit: {count: 10}
orderBy: {descending: Block_Time}
) {
Price {
BtoA {
Price
MinAmountOut
MaxAmountIn
}
AtoB {
Price
MinAmountOut
MaxAmountIn
}
Pool {
PoolId
SmartContract
Pair {
Decimals
SmartContract
Name
}
CurrencyB {
Symbol
SmartContract
Name
Decimals
}
CurrencyA {
Symbol
SmartContract
Name
Decimals
}
}
Dex {
SmartContract
ProtocolVersion
ProtocolName
ProtocolFamily
}
SlippageBasisPoints
}
Block {
Time
Number
}
}
}
}
Note: This query can be converted to a subscription to monitor in real-time. Simply replace
querywithsubscriptionto receive live updates whenever the pool's liquidity changes.
Realtime Slippage for Uniswap V4 Pools
This subscription query retrieves real-time slippage data for Uniswap V4 pools on Ethereum. Unlike Uniswap V3, which uses the pool's smart contract address, Uniswap V4 requires using the PoolId to identify pools. In Uniswap V4, liquidity is managed by a centralized pool manager contract.
You can find the query here
subscription {
EVM(network: eth) {
DEXPoolSlippages(
where: {Price: {Pool: {PoolId: {is: "0x89c10991af36a29d4a14b346a272baa7205d2b41c72013f61cfca41ef2666412"}}}}
) {
Price {
BtoA {
Price
MinAmountOut
MaxAmountIn
}
AtoB {
Price
MinAmountOut
MaxAmountIn
}
Pool {
PoolId
SmartContract
Pair {
Decimals
SmartContract
Name
}
CurrencyB {
Symbol
SmartContract
Name
Decimals
}
CurrencyA {
Symbol
SmartContract
Name
Decimals
}
}
Dex {
SmartContract
ProtocolVersion
ProtocolName
ProtocolFamily
}
SlippageBasisPoints
}
Block {
Time
Number
}
}
}
}
Realtime Slippage Data via Kafka Streams
Slippage data can also be obtained via Kafka streams for lower latency and better reliability. The Kafka topic for Ethereum DEX pools is:
ethereum.dexpools.proto
Kafka streams provide the same slippage data as GraphQL subscriptions but with several advantages:
- Lower latency due to shorter data pipeline
- Better reliability with persistent connections
- Ability to read from latest offset without gaps
- Better scalability with multiple consumers
For detailed information on how to connect to Kafka streams, subscribe to topics, and parse messages, refer to the Kafka Streaming Concepts documentation.
Note: IDE credentials will not work with Kafka Streams. You need separate Kafka credentials. Please contact sales on our official telegram channel or fill out the form on our website.
Understanding the Response
The DEXPoolSlippages API response contains the following information:
-
Price: Price information for swaps at a specific slippage toleranceAtoB: Price data for swapping CurrencyA to CurrencyBPrice: Average execution price for swaps at this slippage levelMinAmountOut: Minimum output amount guaranteed at this slippage levelMaxAmountIn: Maximum input amount that can be swapped at this slippage level
BtoA: Price data for swapping CurrencyB to CurrencyA (same structure as AtoB)SlippageBasisPoints: Slippage tolerance in basis points (100 = 1%)Pool: Pool information including token pair detailsDex: DEX protocol information (Uniswap V2, V3, V4, etc.)
-
Block: Block information when the slippage data was recordedTime: Timestamp of the blockNumber: Block number
For more details on how slippage is calculated and when new pool records are emitted, see the DEXPools Cube documentation.
Use Cases
Liquidity Depth Analysis
Use the slippage API to analyze which pools can handle large trades without significant price impact. By examining MaxAmountIn values at different slippage levels, you can:
- Identify pools with sufficient liquidity for your trade size
- Determine optimal slippage tolerance settings
- Estimate price impact before executing trades
Multi-Pool Price Comparison
Compare execution prices across different pools and slippage scenarios to:
- Find the best pool for your specific trade size
- Understand price differences between DEX protocols
- Optimize trade execution strategies
Trading Applications
Live Execution Testing
Use the slippage API to test and validate trade execution strategies in real-time:
- Pre-trade validation: Check if your intended trade size can be executed within acceptable slippage bounds before submitting
- Execution simulation: Calculate expected price impact and minimum output amounts for different trade sizes
- Strategy backtesting: Monitor historical slippage data to validate trading algorithms and optimize entry/exit points
- Risk assessment: Evaluate maximum position sizes that can be entered without exceeding your slippage tolerance
Detecting Liquidity Shocks and Toxic Order Flow
The slippage API helps identify temporary price dislocations and liquidity shocks that can be exploited or avoided:
- Flow toxicity detection: Monitor sudden changes in
MaxAmountInvalues to detect when pools experience large outflows or inflows - Price impact analysis: Track how
MinAmountOutchanges relative toMaxAmountInto identify when pools become less liquid - Mean reversion opportunities: Identify pools where large swaps have created temporary price dislocations that may revert
- Toxic order flow avoidance: Use slippage data to avoid entering positions when liquidity is thin or when large trades are likely to move price against you
For a practical implementation example of using slippage data for automated trading strategies, including flow toxicity detection and mean-reversion trading, see the AMM Flow Toxicity Alpha Engine repository. This system demonstrates how to:
- Detect large swaps that move price significantly (50-500 basis points)
- Verify isolation from trending markets
- Execute fade trades against temporary price impacts
- Manage positions with dynamic stop losses and take profits based on slippage data
For more advanced use cases, refer to the DEXPools Cube documentation.