Skip to content
Dune Analytics

@kroeger0x / Top DEX Pairs, Trailing 4 Weeks

Top DEX Pairs, Trailing 4 Weeks

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
2prices AS (                                                                                       
3    SELECT minute,                                                         
4        contract_address,                                                                              
5        price
6    FROM prices.usd                                                                                    
7    WHERE minute > now() - interval '28 days'
8)
9, pair_volume AS (
10    select
11        CASE
12            WHEN token_a.symbol IS NULL OR token_b.symbol IS NULL THEN
13                CASE
14                    WHEN COALESCE(token_a.symbol,t.token_a_address::VARCHAR) > COALESCE(token_b.symbol,t.token_b_address::VARCHAR)
15                        THEN COALESCE(token_a.symbol,t.token_a_address::VARCHAR)  || '-' || COALESCE(token_b.symbol,t.token_b_address::VARCHAR)
16                    ELSE COALESCE(token_b.symbol,t.token_b_address::VARCHAR)  || '-' || COALESCE(token_a.symbol,t.token_a_address::VARCHAR)
17                END
18            WHEN token_a.symbol < token_b.symbol THEN token_a.symbol || '-' || token_b.symbol
19            ELSE token_b.symbol || '-' || token_a.symbol
20        END AS pair
21        , (
22            CASE WHEN token_a_address = a.contract_address THEN token_a_amount * a.price -- Use token A when there's USD price for it                    
23            ELSE token_b_amount * b.price -- Else use token b                             
24            END   
25            ) AS usd_volume...

SQL query results

Loading
 

Result visualizations

Top DEX Pairs, Trailing 4 Weeks

Loading