Skip to content
Dune Analytics

@ashachaf / Bancor USD Hourly volume (24h view)

Bancor USD Hourly volume (24h view)


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


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" 
16SELECT date_trunc('hour', 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 '1 days'