jackguy$NEAR Swap Outflows copy
Updated 2023-03-13
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 64188ebe-e369-4feb-b159-6bf8972b7063
with tab1 as (
SELECT
date_trunc('week', timestamp) as day,
symbol,
avg(price_usd) as price
FROM near.core.fact_prices
GROUP BY 1,2
), tab0 as (
SELECT
signer_id,
min(date_trunc('day', block_timestamp)) as first_day,
count(DISTINCT tx_hash) as profile_change_events
FROM near.social.fact_addkey_events
GROUP BY 1
)
SELECT
date_trunc('week', block_timestamp) as day,
TOKEN_OUT,
count(DISTINCT tx_hash) as swaps,
sum(price * amount_out) as volume
FROM near.core.ez_dex_swaps
LEFT outer JOIN tab1
on date_trunc('day', block_timestamp) = DAY
AND symbol = TOKEN_OUT
WHERE trader in (
SELECT
DISTINCT signer_id
FROM tab0
WHERE first_day BETWEEN '{{ user_group_first_day }}' AND '{{ user_group_last_day }}'
)
--and not token_out like 'WBTC'
--LIMIT 100
Run a query to Download Data