Deebs-DeFi-j9fRbzSUM ETH
Updated 2023-06-14
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 ETH Buy and Sell @ https://flipsidecrypto.xyz/edit/queries/3dd736dd-e4fe-4805-a12a-8282f2f88fe7
WITH buys AS(
select
CASE
WHEN token_out=lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') THEN 'BOUGHT'
END AS ACTION,
SUM(amount_out) AS total_bought_sold
from ethereum.core.ez_dex_swaps
WHERE BLOCK_TIMESTAMP BETWEEN {{start_date}} AND {{end_date}}
AND token_out=lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
group by 1
),
sells AS(
select
CASE
WHEN token_in=lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') THEN 'SOLD'
END AS ACTION,
SUM(amount_in) AS total_bought_sold
from ethereum.core.ez_dex_swaps
WHERE BLOCK_TIMESTAMP BETWEEN {{start_date}} AND {{end_date}}
AND token_in=lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
group by 1
)
SELECT
action,
total_bought_sold
FROM buys
UNION ALL
SELECT
action,
total_bought_sold
FROM sells
--LEFT JOIN sells s on b.token_in=s.token_out
--LIMIT 100;
Run a query to Download Data