Skip to content
Dune Analytics

@danrobinson / Cumulative Uniswap volume

Cumulative Uniswap volume

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

1WITH prices AS
2  (SELECT MINUTE,
3          contract_address,
4          price
5   FROM prices.usd)
6SELECT day,
7       uniswap_version,
8       SUM(usd_volume) OVER (PARTITION BY uniswap_version
9                             ORDER BY DAY) as cumulative_usd_volume
10FROM
11  (SELECT date_trunc('day', block_time) AS DAY,
12          uniswap_version,
13          SUM( CASE
14                   WHEN token_a_address = a.contract_address THEN token_a_amount * a.price -- Use token A when there's USD price for it                    
15 
16                   ELSE token_b_amount * b.price -- Else use token b                             
17 
18               END ) AS usd_volume
19   FROM 
20     (SELECT *, 
21             (CASE 
22                  WHEN VERSION = '1' THEN 'v1' 
23                  ELSE 'v2' 
24              END) AS uniswap_version
25      FROM dex."trades" t ...

SQL query results

Loading
 

Result visualizations

Cumulative Uniswap volume

Loading