Skip to content

Commit

Permalink
Merge branch 'v3-outline' of https://github.com/balancer/docs-v3 into…
Browse files Browse the repository at this point in the history
… v3-outline
  • Loading branch information
mkflow27 committed Jun 6, 2024
2 parents 2d2911b + d172cf0 commit e8c79aa
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 15 deletions.
15 changes: 0 additions & 15 deletions docs/data-and-analytics/data-and-analytics/dune.md

This file was deleted.

36 changes: 36 additions & 0 deletions docs/data-and-analytics/data-and-analytics/dune/dashboards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
order: 3
---

# Dashboards

**Balancer Labs' data team** works on building dashboards where internal and external stakeholders can gather as much information as possible on the protocol.

If you have any questions/feedback on our dashboards, feel free to reach out by filling out this [form](https://docs.google.com/forms/d/e/1FAIpQLScHCgRxCGfyJp02Dl_nK6shDnXY1FDDXpsd-sqjTeIsv5EteQ/viewform) or directly on [Discord](https://discord.balancer.fi/).

**Here i a run-down of our dashboards:**

| Dashboard Name | Main information | Filters |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
| [veBAL](https://dune.com/balancer/vebal) | Total veBAL, veBAL locking, power by top LPs, votes by gauge and network | |
| [veBAL Analysis](https://dune.com/balancer/vebal-analysis) | Power and votes by provider | Provider |
| [veBAL Gauge Votes](https://dune.com/balancer/vebal-gauge-analysis) | Voters on gauge | Gauge |
| [Balancer Overview](https://dune.com/balancer/overview) | Volume (by source, cumulative, 24h and 7d), TVL, average swap fees, liquidity utilization, Balancer on 1inch and cowswap | Pool ID, Start Date, End Date, and blockchain |
| [Balancer Exchange](https://dune.com/balancer/exchange) | Volume (by token, 24h and 7d), # of swaps, new/old traders, fees distribution, gas costs | Aggregation, Start Date, End Date, and blockchain |
| [Balancer Report](https://dune.com/balancer/report) | TVL, Volume (cumulative, market share, by token), swap fees revenue | Pool ID, Start Date, End Date, and blockchain |
| [TVL](https://dune.com/balancer/tvl) | Daily data for TVL, by chain and pool | Date Range in Days, Pool Rank by Daily TVL |
| [Volume](https://dune.com/balancer/volume) | 24h, 7d, 30d, moving averages, volume by pool, daily volume changes, by blockchain (median swap, # of swaps, new traders, Net token inflow/outflow | |
| [Balancer Volume Breakdown](https://dune.com/balancer/volume-breakdown) | Overview on volume by token, pool, and source | Source Address, -Source Name, Pool ID, Start Date, End Date, and blockchain |
| [Balancer Volume - Source Breakdown](https://dune.com/balancer/volume-source-breakdown) | Weekly, daily, and hourly volume breakdown by source (DEXs and Aggregators, Heavy Traders and MEV bots). Addresses used are listed on this [link](https://dune.com/queries/3004790) | Source Address, -Source Name, Pool ID, Start Date, End Date, and blockchain |
| [Balancer Volume - Pool Breakdown](https://dune.com/balancer/volume-pool-breakdown) | Weekly, daily, and hourly volume breakdown by top pools | Start Date, End Date, and blockchain |
| [Balancer Volume - Token Breakdown](https://dune.com/balancer/volume-token-breakdown) | All-time volume by token, Monthly and hourly top tokens volume | Blockchain, Aggregation, Top x tokens |
| [Pools Overview](https://dune.com/balancer/pools) | Balancer Pools, TVL, Volume (24h, 7d), Pools Created (by blockchain and pool type), Fees distribution | Start Date, End Date, and blockchain |
| [Pool Analysis](https://dune.com/balancer/pool-analysis) | Volume (daily, 24h, 7d, by source), TVL, Swap Fees, LPs, Liquidity Utilization | Pool ID, Start Date, End Date, and blockchain |
| [8020 Initiative](https://dune.com/balancer/8020-initiative) | ve8020 Pools, TVL, Impermanent Loss, Price Volatility, Pool Balancer, Volume by Source | Blockchain, Pool Address |
| [Built on Balancer](https://dune.com/balancer/built-on-balancer) | TVL, volume and Liquidity Utilization for projects built on Balancer | Project, Start Date |
| [Balancer Governance](https://dune.com/balancer/governance) | BAL Minted, holders, LPs, price, supply, emission rates | |
| [Balancer V2 LBPs](https://dune.com/balancer/v2-lbps) | Volume, amount raised, transactions, participants, tokens sold, indirect volume | LBP |
| [Gas Costs](https://dune.com/balancer/gas-costs) | Gas Costs per swap, pool_type and blockchain | TimeFrame, days, Pool Type, blockchain |
| [Balancer V2 Revenues Overview](https://dune.com/balancer/v2-revenues) | Weekly swap fee revenues, LP revenues by pool and token | Pool ID, Start Date, End Date, blockchain, and Token Address |
| [Protocol Fees](https://dune.com/balancer/protocol-fees) | Protocol Fees Collected per pool, blockchain, pool type, Fees Collected and BAL emissions per round, Core Pools Fees Collected per Epoch| Pool ID, Start Date, End Date, blockchain, Only Core Pools, Round ID, Fee Epoch |
| [LSTs](https://dune.com/balancer/lst) | Liquidity, Volume, Fees Collected and Liquidity Utilization on LST Pools and tokens | Pool ID, Start Date, End Date, blockchain, and Token Address |
13 changes: 13 additions & 0 deletions docs/data-and-analytics/data-and-analytics/dune/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
order: 1
---

# Overview

Welcome to Balancer's data analytics powered by Dune!

[Dune Analytics](https://dune.com/home) is a powerful data analytics platform that enables users to explore, query, and visualize on-chain data from various DeFi protocols, including Balancer. It provides a user-friendly interface to interact with blockchain data, empowering both data analysts and DeFi enthusiasts to gain valuable insights.

Balancer Labs' data team is dedicated to providing with up-to-date and comprehensive analytics. We constantly update our Dune [dashboards](https://dune.com/browse/dashboards?team=balancer), spells [spells](https://github.com/duneanalytics/spellbook/tree/main/models/balancer), and [queries](https://dune.com/browse/queries?team=balancer) to ensure that you have access to the latest information on Balancer Protocol.

Explore our Dune dashboards, dive into the data, and discover the insights that matter most to you. If you have any questions or need assistance with specific queries, feel free to reach out by filling out this [form](https://docs.google.com/forms/d/e/1FAIpQLScHCgRxCGfyJp02Dl_nK6shDnXY1FDDXpsd-sqjTeIsv5EteQ/viewform) or directly on [Discord](https://discord.balancer.fi/).
148 changes: 148 additions & 0 deletions docs/data-and-analytics/data-and-analytics/dune/spells.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
order: 2
---

# Spells

## Introduction

Unlock the power of Balancer data with our meticulously crafted Dune Spells!
Balancer Labs' data team is dedicated to the relentless pursuit of excellence, continuously refining and updating our Dune Spells to deliver the most accurate, insightful, and up-to-date analytics for the Balancer community.


## Explore the Spellbook

Embark on your journey through the world of Balancer's data by exploring our Spellbook. Visit [https://github.com/duneanalytics/spellbook/tree/main/models/balancer](https://github.com/duneanalytics/spellbook/tree/main/models/balancer) to delve into the intricacies of our models, gaining access to the very spells that empower your understanding of Balancer's ecosystem.

**Here are the updated dashboards:**

| Spell | Description | Upstream Spells | Chains |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------ |
| [balancer_trades](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_trades.sql) | All trades on Balancer, with information on date, tx_hash, tx_from, tx_to, tokens, amounts, version of Balancer in which the trade happened, the pool and its respective swap fee | balancer_v1_ethereum_trades, balancer_v2_[chain]_trades | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_liquidity](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_liquidity.sql) | Daily liquidity information for balancer pools, by each token contained in a pool. It is also divided in pool_liquidity_usd, which also includes BPTs (Balancer Pool Tokens) balances and and protocol_liquidity_usd, which excludes BPTs. | balancer_v1_ethereum_liquidity, balancer_v2_[chain]_liquidity | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_pools_fees](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_pools_fees.sql) | Balancer v2 swap fees stored at the pool level, including information on the transaction where the fee was set. | balancer_v2_[chain]_pools_fees | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_protocol_fees](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_protocol_fees.sql) | Daily Protocol Fee collected and Treasury Revenue by pool and token. | balancer_v2_[chain]_protocol_fees | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_bpt_supply](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_bpt_supply.sql) | BPT supply over time of ComposableStablePools versions 4+ | balancer_v2_[chain]_bpt_supply | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_bpt_prices](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_bpt_prices.sql) | Balancer Pool Token (BPT) hourly median price by pool. | balancer_v2_[chain]_bpt_prices | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_flashloans](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_flashloans.sql) | All Balancer flashloans | balancer_v2_[chain]_flashloans | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_transfers_bpt](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/balancer_transfers_bpt.sql) | Balancer Pool Token (BPT) transfer logs on Balancer, | balancer_v2_[chain]_transfers_bpt | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_[chain]_pools_tokens_weights](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/ethereum/balancer_[chain]_pools_tokens_weights.sql) | Token weights in Balancer’s weighted pools | balancer_v2_[chain]_pools_tokens_weights | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [balancer_ethereum_balances](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/ethereum/balancer_ethereum_balances.sql) | Daily running cumulative balance for ERC20 tokens on balancer v1 pools | | Ethereum |
| [balancer_ethereum_vebal_slopes](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/ethereum/balancer_ethereum_vebal_slopes.sql) | Slope and bias of veBAL per wallet after each balance update | | Ethereum |
| [balancer_ethereum_vebal_balances_day](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/ethereum/balancer_ethereum_vebal_balances_day.sql) | Daily balances of veBAL per wallet | | Ethereum |
| [balancer_ethereum_vebal_votes](https://github.com/duneanalytics/spellbook/blob/main/models/balancer/ethereum/balancer_ethereum_vebal_votes.sql) | Records of votes for Balancer gauges by provider at each voting round | | Ethereum |
| [labels_balancer_v1_pools](https://github.com/duneanalytics/spellbook/blob/main/models/labels/addresses/__single_category_labels__/balancer_v1/labels_balancer_v1_pools.sql) | Names Balancer v1 pools, based on tokens and weights | labels_balancer_v1_pools_ethereum | Ethereum |
| [labels_balancer_v2_pools](https://github.com/duneanalytics/spellbook/blob/main/models/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_pools.sql) | Names Balancer v2 pools, based on tokens and weights. Also returns pool type. | labels_balancer_v2_pools_{{chain}} | Arbitrum, Avalanche, Base, Ethereum, Gnosis, Optimism, Polygon PoS, Polygon ZkEVM |
| [labels_balancer_v2_gauges](https://github.com/duneanalytics/spellbook/blob/main/models/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_gauges.sql) | Names Balancer v2 gauges, based on their respective blockchain and pool | labels_balancer_v2_gauges_{{chain}} | |


## Contribute to the Magic

We invite you to not only explore but also contribute to the magic. As we strive for excellence, collaboration is at the heart of our mission. Your insights, feedback, and contributions are invaluable in shaping the future of Balancer's data analytics.
To do so, you can create pull requests to Dune's spellbook or reach out to Balancer Labs' data team directly on [Discord](https://discord.balancer.fi/).

**You can leverage our spells with queries such as:**


## 1, 7 and 30 day volume on Balancer

```sql
SELECT
SUM(amount_usd)/1e6 AS "Volume on Balancer"
, 1 AS rn
FROM balancer.trades
WHERE block_time >= CAST(NOW() AS TIMESTAMP) - INTERVAL '1' DAY

UNION ALL

SELECT
SUM(amount_usd)/1e6 AS "Volume on Balancer"
, 2 AS rn
FROM balancer.trades
WHERE block_time >= CAST(NOW() AS TIMESTAMP) - INTERVAL '7' DAY

UNION ALL

SELECT
SUM(amount_usd)/1e6 AS "Volume on Balancer"
, 3 AS rn
FROM balancer.trades
WHERE block_time >= CAST(NOW() AS TIMESTAMP) - INTERVAL '30' DAY
ORDER BY rn ASC
```

## All swaps on the last 24 hours

```sql
SELECT
block_date
, tx_hash
, project_contract_address AS pool_address
, token_bought_address
, token_bought_amount
, token_sold_address
, token_sold_amount
, tx_from
, tx_to
, amount_usd
, swap_fee
FROM balancer.trades
WHERE block_time >= now() - interval '24' hour
ORDER BY 1 ASC
```

## Daily TVL by Blockchain

```sql
SELECT
blockchain
, CAST(day AS TIMESTAMP) AS day
, sum(protocol_liquidity_usd) AS chain_tvl
FROM balancer.liquidity x
GROUP BY 1, 2
ORDER BY 2 DESC, 3 DESC
```

## Current TVL by pool, from highest to lowest

```sql
SELECT
blockchain
, pool_id
, pool_symbol
, sum(pool_liquidity_usd) AS pool_tvl
FROM balancer.liquidity x
WHERE day >= current_date
GROUP BY 1, 2, 3
ORDER BY 4 DESC
```

## Daily Liquidity Utilization

```sql
WITH
swaps AS (
SELECT
date_trunc('day', d.block_time) AS day
, SUM(amount_usd) AS volume
FROM balancer.trades d
)
GROUP BY 1
),

total_tvl AS (
SELECT
CAST(day as timestamp) as day
, SUM(protocol_liquidity_usd) AS tvl
FROM balancer.liquidity
)
GROUP BY 1
)

SELECT
CAST(t.day as timestamp) as day,
(s.volume)/(t.tvl) AS liquidity_utilization,
FROM total_tvl t
LEFT JOIN swaps s ON s.day = t.day
ORDER BY 1
```

0 comments on commit e8c79aa

Please sign in to comment.