Skip to content
Dune Analytics

@k06a / 1inch.exchange 24h Top Traders

SQL query

1SELECT
2    ROW_NUMBER() OVER () as idx,
3    sender,
4    volume,
5    trades
6FROM (
7    SELECT
8        ROW_NUMBER() OVER (ORDER BY 4 DESC),
9        CONCAT('0x', ENCODE(tx_from, 'hex')) as sender,
10        COUNT(*) as trades,
11        SUM(GREATEST(from_usd, to_usd)) AS volume
12    FROM
13    (
14        SELECT to_token, from_token, to_amount, from_amount, tx_hash, block_time, from_usd, to_usd, tx_from FROM oneinch.view_swaps UNION All
15        SELECT to_token, from_token, to_amount, from_amount, tx_hash, block_time, from_usd, to_usd, tx_from FROM onesplit.view_swaps
16        WHERE tx_hash NOT IN (SELECT tx_hash FROM oneinch.view_swaps)
17    ) oi
18    WHERE DATE_PART('Day', now() - oi.block_time::timestamptz) < 1
19    GROUP BY 2
20    ORDER BY 4 DESC NULLS LAST
21) tt
22

SQL query results

Loading