yasmin-n-d-r-h Top 5 users by the number of swaps and volume
Updated 2023-05-15
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH price AS (
SELECT
date_trunc('day', RECORDED_HOUR) AS hour,
avg(close) AS usd_price
FROM
flow.core.fact_hourly_prices
WHERE
TOKEN = 'Flow'
GROUP BY
1
),
swap_data AS (
SELECT
ez.trader,
count(DISTINCT ez.tx_id) AS num_swaps,
sum(ez.TOKEN_IN_AMOUNT * p.usd_price) AS total_volume
FROM
flow.core.ez_swaps AS ez
JOIN flow.core.fact_transactions AS ft ON ez.tx_id = ft.tx_id
JOIN price AS p ON date_trunc('day', ez.block_timestamp) = p.hour
WHERE
ft.PROPOSER = '0x55ad22f01ef568a1'
AND ft.PAYER = '0x55ad22f01ef568a1'
AND ez.block_timestamp >= '2023-01-01'::TIMESTAMP
GROUP BY
ez.trader
)
SELECT
trader,
num_swaps,
total_volume
FROM
swap_data
ORDER BY
num_swaps DESC --total_volume DESC
LIMIT 5;
Run a query to Download Data