Skip to content
Dune Analytics

@ashachaf / Bancor USD Daily volume (30 days view)

Bancor USD Daily volume (30 days view)

Loading
 

About queries and results

Dune Analytics lets you explore, create, and share Ethereum analytics. You can find an endless amount of great queries and dashboards on Dune.

We have decoded Ethereum smart contract data so you can do powerful analysis with simple SQL queries and visualise the query results into beautiful graphs.

Dune Analytics is free for everyone forever. If you want extra features like private queries, export your results and more check out our Pro plan.

SQL query results

Loading
 

SQL query

1WITH conversions AS (
2    SELECT 
3        source_token_amount, 
4        CASE WHEN source_token_address = '\xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' THEN
5            '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'::bytea -- use weth
6        ELSE source_token_address
7        END AS source_token_address,
8        target_token_amount,
9        CASE WHEN target_token_address = '\xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' THEN
10            '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'::bytea -- use weth
11        ELSE target_token_address
12        END AS target_token_address,
13        block_time
14    FROM bancornetwork."view_convert" 
15)
16SELECT date_trunc('days', block_time) AS t,
17       SUM(COALESCE(
18        (SELECT source_token_amount * price FROM prices.USD WHERE date_trunc('minute', block_time) = minute AND source_token_address=contract_address),
19        (SELECT target_token_amount * price FROM prices.USD WHERE date_trunc('minute', block_time) = minute AND target_token_address=contract_address)
20    )) AS volume  -- Use token A when there's an USD price for it, else token B
21FROM conversions s
22WHERE block_time > now() - interval '30 days'
23GROUP BY t
24ORDER BY t
25;...