Skip to content
Dune Analytics

@hagaetc / DEX Trailing 7 days growth 📈

DEX Trailing 7 days growth 📈

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                                                                                    
6    WHERE minute > now() - interval '14 days'
7)                                                                                                      
8
9, volume AS
10
11(
12SELECT 
13    CASE WHEN block_time > now() - interval '7 days' THEN  '2' 
14    ELSE '1'
15    END AS week,
16    SUM(COALESCE(
17        usd_amount,                 -- Use USD amount directly if available in dex.trades table
18        token_a_amount * a.price,   -- If no USD amount multiply token A with USD price 
19        token_b_amount * b.price    -- Else multiply token B with USD price
20    )) as usd_volume                                                                             
21FROM dex."trades" t                                                                             
22LEFT JOIN prices a ON date_trunc('minute', block_time) = a.minute AND token_a_address = a.contract_address 
23LEFT JOIN prices b ON date_trunc('minute', block_time) = b.minute AND token_b_address = b.contract_address 
24WHERE block_time > now() - interval '14 days'
25AND project != '1inch'...

SQL query results

Loading