Skip to content
Dune Analytics

@k06a / 1inch.exchange Overall Referrals

SQL query

1SELECT
2    ROW_NUMBER() OVER () as idx,
3    sender,
4    trades,
5    volume
6FROM (
7    SELECT
8        ROW_NUMBER() OVER (ORDER BY 4 DESC),
9        CONCAT('0x', ENCODE(tx.ref, 'hex')) as sender,
10        COUNT(*) as trades,
11        SUM(
12            GREATEST(
13                oi."fromAmount" * (
14                    CASE
15                        WHEN oi."fromToken" = '\xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN 
16                            (
17                                SELECT p.price
18                                FROM prices."usd" p
19                                WHERE p.contract_address is NULL
20                                ANd p.symbol = 'ETH'
21                                AND p.minute = date_trunc('minute', tx.block_time)
22                                LIMIT 1
23                            )
24                        ELSE
25                            (...

SQL query results

Loading