Afonso_DiazTotal
Updated 2024-07-12
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
›
⌄
WITH tab1 AS (
SELECT
from_address AS user
,ABS(nvl(amount0_usd, amount1_usd)) AS amount_usd
,a.tx_hash
,a.block_timestamp::date as dt
,CASE WHEN dt<'2023-10-17' THEN 'without fee'
WHEN dt>='2023-10-17' AND dt<='2024-04-10' THEN 'introducing 0.15% fee'
ELSE 'introducing 0.25% fee'
END AS timeEvent
FROM ethereum.uniswapv3.ez_swaps a
JOIN ethereum.core.fact_transactions b
ON a.tx_hash=b.tx_hash
WHERE dt>='2023-10-17'
AND amount_usd>0
AND amount_usd IS NOT NULL
AND amount_usd<10000000
AND EXISTS (
SELECT * FROM ethereum.core.ez_decoded_event_logs c WHERE to_address IN (LOWER('0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b'), LOWER('0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad'))
AND a.tx_hash=c.tx_hash
)
)
SELECT
COUNT(DISTINCT(tx_hash)) AS "swaps"
,COUNT(DISTINCT user) AS "users"
,SUM(amount_usd) AS "volume($)"
,AVG(amount_usd) AS "avg volume($)"
,timeEvent AS "type"
FROM tab1
GROUP BY "type"
QueryRunArchived: QueryRun has been archived