jackguyTop 100 NEAR Dex users by swap volume usd
Updated 2023-05-09
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
›
⌄
-- forked from Top 100 Ref Finance users by swap volume usd @ https://flipsidecrypto.xyz/edit/queries/af4ebc31-6084-4683-885f-bbadc538864f
with tab11 as (
SELECT
date_trunc('day', hour) as day1,
symbol as symbol1,
avg(price) as daily_price1
FROM ethereum.core.fact_hourly_token_prices
GROUP BY 1,2
--WHERE blockchain LIKE 'near'
--LIMIT 100
), tab1 as (
SELECT
date_trunc('day', timestamp) as day2,
token_contract,
symbol as saymbol2,
median(price_usd) as daily_price2
FROM near.core.fact_prices
GROUP BY 1,2,3
), tab3 as (
SELECT
date_trunc('day', timestamp) as day3,
token_contract as token_contract3,
symbol as saymbol3,
median(price_usd) as daily_price3
FROM near.core.fact_prices
GROUP BY 1,2,3
)
SELECT
trader,
sum(CASE when NOT daily_price1 is NULL then daily_price1 * amount_out
when NOT daily_price2 is NULL then daily_price2 * amount_out
when NOT daily_price3 is NULL then daily_price3 * amount_in
else 0 end) as volume_usd,
count(DISTINCT tx_hash) as swaps,
Run a query to Download Data