Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
sidebar_position: 2
---

import VideoPlayer from "../../../../../src/components/videoplayer.js";

# Ethereum Validator Balance Tracker

The Ethereum Validator Balance Tracker API provides real-time balance updates for Ethereum validators, tracking their staking rewards, withdrawals, and balance changes.

<VideoPlayer url="https://www.youtube.com/watch?v=mEvrPCeOx7I" />
For a sample application, see the [Validators Rewards Tax Calculator](https://docs.bitquery.io/crypto-reward-tax-calculator).

<head>
<meta name="title" content="Ethereum Validator Balance Tracker API & Streams"/>
Expand Down Expand Up @@ -309,6 +307,8 @@ query MyQuery {
}
```

## Real World Projects Using Bitquery
## Video Tutorial

- [Crypto Rewards Tax Calculator](https://docs.bitquery.io/crypto-reward-tax-calculator)
import VideoPlayer from "../../../../../src/components/videoplayer.js";

<VideoPlayer url="https://www.youtube.com/watch?v=mEvrPCeOx7I" />
103 changes: 103 additions & 0 deletions docs/cubes/evm-dexpool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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.

## 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 information
- **`Dex`**: The DEX protocol details (name, version, family)
- **`Liquidity`**: Current token reserves in the pool
- **`PoolPriceTable`**: Price calculations for different slippage tolerances in both directions

### Example Data Structure

A sample entry for a token pair shared via Bitquery Kafka streams is available [here](https://github.com/bitquery/kafka-data-sample/blob/main/evm/eth_dexpools.json)

### Understanding Price Tables

The `PoolPriceTable` provides price information for swaps in both directions:

- **`AtoBPrices`**: Array of price calculations for swapping CurrencyA to CurrencyB at different slippage tolerances
- **`BtoAPrices`**: Array of price calculations for swapping CurrencyB to CurrencyA at different slippage tolerances
- **`AtoBPrice`**: Current spot price for CurrencyA to CurrencyB
- **`BtoAPrice`**: Current spot price for CurrencyB to CurrencyA

Each price entry in the arrays contains:
- **`SlippageBasisPoints`**: Slippage tolerance in basis points (100 = 1%)
- **`MaxAmountIn`**: Maximum input amount that can be swapped at this slippage level
- **`MinAmountOut`**: Minimum output amount guaranteed at this slippage level
- **`Price`**: Average execution price for swaps at this slippage level

For example, in the `AtoBPrices` array above, with a 10 basis point (0.1%) slippage tolerance, you can swap up to 2,557,952,147 units of CurrencyA (USDC) and receive at least 860,478,002,991,619,427 units of CurrencyB (WETH), at an average price of 0.0003364734002389014 USDC per WETH.

## When is a new DEXPool record emitted in the APIs & Streams?


## Filtering in DEXPools Cube

Filtering helps to fetch the exact pool data you are looking for. DEXPools Cube can filter based on pool address, token addresses, DEX protocol, liquidity amounts, and more.

Everything inside the "where" clause filters; it follows the `AND` condition by default.

## Advanced Use Cases and Processing Patterns

### Liquidity Depth Analysis

DEXPools enables analysis of liquidity depth across different pools. By examining the `MaxAmountIn` values at various slippage levels, you can determine:

- Which pools can handle large trades without significant price impact
- Optimal slippage tolerance for your trade size
- Price impact estimation before executing trades

### Multi-Pool Price Comparison

The price table data allows comparison of execution prices across different slippage scenarios, helping traders:

- Identify the best pool for their trade size
- Understand price impact before executing swaps
- Optimize trade execution strategies based on available liquidity

### Protocol-Specific Analysis

Different DEX protocols (Uniswap V2, V3, V4) have different liquidity mechanisms. The DEXPools cube provides protocol-specific information:

- **Uniswap V2/V3**: Liquidity reflects the exact balance of the pool
- **Uniswap V4**: Liquidity represents token balances in PoolManager

This allows for accurate analysis across different protocol versions and their unique characteristics.
4 changes: 4 additions & 0 deletions docs/streams/kafka-streaming-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,19 @@ All the topics send data in the **protobuf** format
- eth.transactions.proto
- eth.tokens.proto
- eth.dextrades.proto
- eth.dexpools.proto
- bsc.transactions.proto
- bsc.tokens.proto
- bsc.dextrades.proto
- bsc.dexpools.proto
- base.transactions.proto
- base.tokens.proto
- base.dextrades.proto
- base.dexpools.proto
- matic.transactions.proto
- matic.tokens.proto
- matic.dextrades.proto
- matic.dexpools.proto
- optimism.transactions.proto
- optimism.tokens.proto
- optimism.dextrades.proto
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ const sidebars = {
"cubes/EVM",
"cubes/dextrades",
"cubes/dextradesbyTokens",
"cubes/evm-dexpool",
"cubes/transaction-cube",
"cubes/balance-updates-cube",
"cubes/transfers-cube",
Expand Down